From dbe6be73a625aa91fba6bdef239fcf9b7d2833b8 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 17 Apr 2018 22:30:12 +0300 Subject: [PATCH 1/2] Added Hexo and NexT environment variables. 1. Replaced Hexo version by full `env` variable. Here is values: https://github.com/hexojs/hexo/blob/373b9c745cb5dfe25e942e720aca2cdac78e1874/lib/hexo/index.js#L47-L55 2. From this moment version of NexT will be readed from `package.json` file. So, no need to set version in NexT `_config.yml` file anymore. Also, all other values from `package.json` can be readed with `next_env('value')` function in template. 3. Edited `package.json` and `bower.json` (correct author values, some tags). --- _config.yml | 4 ---- bower.json | 5 ++--- layout/_layout.swig | 3 +++ layout/_partials/footer.swig | 4 ++-- layout/_partials/head/head.swig | 12 ++++++------ layout/_scripts/boostrap.swig | 2 +- layout/_scripts/commons.swig | 2 +- layout/_scripts/pages/post-details.swig | 4 ++-- layout/_scripts/schemes/gemini.swig | 2 +- layout/_scripts/schemes/pisces.swig | 2 +- layout/_third-party/exturl.swig | 2 +- layout/_third-party/scroll-cookie.swig | 4 ++-- .../_third-party/search/algolia-search/assets.swig | 2 +- package.json | 10 ++++------ scripts/helpers.js | 13 +++++++++---- 15 files changed, 36 insertions(+), 35 deletions(-) diff --git a/_config.yml b/_config.yml index 5007812b87..4fe6d49c0d 100644 --- a/_config.yml +++ b/_config.yml @@ -960,7 +960,3 @@ vendors: css: css js: js images: images - -# Theme version -version: 6.2.0 - diff --git a/bower.json b/bower.json index c9a9e910b4..a00a57c20d 100644 --- a/bower.json +++ b/bower.json @@ -3,15 +3,14 @@ "version": "6.2.0", "homepage": "https://theme-next.org", "authors": [ - "iissnan ", - "Ivan Nginx (https://almostover.ru)" + "NexT (https://theme-next.org)" ], "description": "Elegant theme for Hexo", "repository": "https://github.com/theme-next/hexo-theme-next", "keywords": [ "hexo", "theme", - "NexT" + "next" ], "license": "AGPL", "ignore": [ diff --git a/layout/_layout.swig b/layout/_layout.swig index fe451f79f2..709e0f40dd 100644 --- a/layout/_layout.swig +++ b/layout/_layout.swig @@ -1,5 +1,8 @@ +{# NexT version #} +{% set version = next_env('version') %} + {% set html_class = 'theme-next ' + theme.scheme %} {% if theme.motion.enable %} {% set html_class = html_class + ' use-motion' %} diff --git a/layout/_partials/footer.swig b/layout/_partials/footer.swig index 99e9f359c3..53e963a0e6 100644 --- a/layout/_partials/footer.swig +++ b/layout/_partials/footer.swig @@ -40,7 +40,7 @@ {% if theme.footer.powered.enable %}
{# - #}{{ __('footer.powered', 'Hexo') }}{% if theme.footer.powered.version %} v{{ hexo_version() }}{% endif %}{# + #}{{ __('footer.powered', 'Hexo') }}{% if theme.footer.powered.version %} v{{ hexo_env('version') }}{% endif %}{# #}
{% endif %} @@ -53,7 +53,7 @@ #}{{ __('footer.theme') }} — {# #}{# #}NexT.{{ theme.scheme }}{# - #}{% if theme.footer.theme.version %} v{{ theme.version }}{% endif %}{# + #}{% if theme.footer.theme.version %} v{{ version }}{% endif %}{# #} {% endif %} diff --git a/layout/_partials/head/head.swig b/layout/_partials/head/head.swig index 65895a2ba9..17782fd1ce 100644 --- a/layout/_partials/head/head.swig +++ b/layout/_partials/head/head.swig @@ -80,19 +80,19 @@ {% endif %} - + {% if theme.favicon.apple_touch_icon %} - + {% endif %} {% if theme.favicon.medium %} - + {% endif %} {% if theme.favicon.small %} - + {% endif %} {% if theme.favicon.safari_pinned_tab %} - + {% endif %} {% if theme.favicon.android_manifest %} @@ -114,7 +114,7 @@ var CONFIG = { root: '{{ theme.root }}', scheme: '{{ theme.scheme }}', - version: '{{ theme.version }}', + version: '{{ version }}', sidebar: {{ theme.sidebar | json_encode }}, fancybox: {{ theme.fancybox }}, fastclick: {{ theme.fastclick }}, diff --git a/layout/_scripts/boostrap.swig b/layout/_scripts/boostrap.swig index 5e950905b1..1bf5ab5b04 100644 --- a/layout/_scripts/boostrap.swig +++ b/layout/_scripts/boostrap.swig @@ -5,5 +5,5 @@ %} {% for bs in boot_scripts %} - + {% endfor %} diff --git a/layout/_scripts/commons.swig b/layout/_scripts/commons.swig index abc2971425..c99e727660 100644 --- a/layout/_scripts/commons.swig +++ b/layout/_scripts/commons.swig @@ -6,5 +6,5 @@ %} {% for common in js_commons %} - + {% endfor %} diff --git a/layout/_scripts/pages/post-details.swig b/layout/_scripts/pages/post-details.swig index 6938779753..c9f7634fb6 100644 --- a/layout/_scripts/pages/post-details.swig +++ b/layout/_scripts/pages/post-details.swig @@ -1,2 +1,2 @@ - - + + diff --git a/layout/_scripts/schemes/gemini.swig b/layout/_scripts/schemes/gemini.swig index 5119eba656..676db4e123 100644 --- a/layout/_scripts/schemes/gemini.swig +++ b/layout/_scripts/schemes/gemini.swig @@ -6,5 +6,5 @@ %} {% for script in scripts %} - + {% endfor %} diff --git a/layout/_scripts/schemes/pisces.swig b/layout/_scripts/schemes/pisces.swig index 5119eba656..676db4e123 100644 --- a/layout/_scripts/schemes/pisces.swig +++ b/layout/_scripts/schemes/pisces.swig @@ -6,5 +6,5 @@ %} {% for script in scripts %} - + {% endfor %} diff --git a/layout/_third-party/exturl.swig b/layout/_third-party/exturl.swig index 329ab506d7..0a416c36d0 100644 --- a/layout/_third-party/exturl.swig +++ b/layout/_third-party/exturl.swig @@ -1,3 +1,3 @@ {% if theme.exturl %} - + {% endif %} diff --git a/layout/_third-party/scroll-cookie.swig b/layout/_third-party/scroll-cookie.swig index 9fbb0ebd58..b4d9d07bf3 100644 --- a/layout/_third-party/scroll-cookie.swig +++ b/layout/_third-party/scroll-cookie.swig @@ -1,4 +1,4 @@ {% if theme.save_scroll %} - - + + {% endif %} diff --git a/layout/_third-party/search/algolia-search/assets.swig b/layout/_third-party/search/algolia-search/assets.swig index 069504f972..07e3222177 100644 --- a/layout/_third-party/search/algolia-search/assets.swig +++ b/layout/_third-party/search/algolia-search/assets.swig @@ -14,5 +14,5 @@ {# E: Include Algolia instantsearch.js library #} - + {% endif %} diff --git a/package.json b/package.json index 341e525fca..e98a7997cd 100644 --- a/package.json +++ b/package.json @@ -14,13 +14,11 @@ "url": "git+https://github.com/theme-next/hexo-theme-next.git" }, "keywords": [ - "NexT", - "Hexo" + "hexo", + "theme", + "next" ], - "author": "iissnan ", - "maintainers": [ - "Ivan Nginx (https://almostover.ru)" - ], + "author": "NexT (https://theme-next.org)", "license": "AGPL", "bugs": { "url": "https://github.com/theme-next/hexo-theme-next/issues" diff --git a/scripts/helpers.js b/scripts/helpers.js index e3ff6ec9fc..03144cd731 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1,5 +1,14 @@ 'use strict'; +hexo.extend.helper.register('hexo_env', function(type) { + return this.env[type]; +}); + +hexo.extend.helper.register('next_env', function(type) { + var env = require('../package.json'); + return env[type]; +}); + hexo.extend.helper.register('item_active', function(path, className) { var canonical = this.page.canonical_path; var current = this.url_for(canonical).replace('index.html', '', 'g'); @@ -12,7 +21,3 @@ hexo.extend.helper.register('item_active', function(path, className) { } return result; }); - -hexo.extend.helper.register('hexo_version', function() { - return this.env.version; -}); From cb469cbaac21a3b4a0dc154bfdf7d2c3a9ecc966 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 17 Apr 2018 22:42:32 +0300 Subject: [PATCH 2/2] Added `require` and `hexo` to excludes. --- .jshintrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index a2d0ed3c5f..1ee527db13 100644 --- a/.jshintrc +++ b/.jshintrc @@ -16,7 +16,9 @@ "$", "jQuery", "NexT", - "CONFIG" + "CONFIG", + "require", + "hexo" ], "quotmark": true, "trailing": true,