forked from theme-next/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom language support feature. (theme-next#253)
* Added custom language support feature. * Fix `hexo` variables in linter by adding `global hexo` comment. * Check Stickler CI. * Error: lines-around-comment * Fix error: lines-around-comment
- Loading branch information
1 parent
725d13d
commit 3b2f980
Showing
19 changed files
with
66 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center"> | ||
<img id="wechat_subscriber_qcode" src="{{ url_for(theme.wechat_subscriber.qcode) }}" alt="{{ theme.author }} wechat" style="width: 200px; max-width: 100%;"/> | ||
<img id="wechat_subscriber_qcode" src="{{ url_for(theme.wechat_subscriber.qcode) }}" alt="{{ author }} wechat" style="width: 200px; max-width: 100%;"/> | ||
<div>{{ theme.wechat_subscriber.description }}</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
/* global hexo */ | ||
|
||
'use strict'; | ||
|
||
var merge = require('./merge'); | ||
|
||
/** | ||
* Merge configs from _data/next.yml into hexo.theme.config. | ||
* Note: configs in _data/next.yml will rewrite or override configs in hexo.theme.config. | ||
*/ | ||
hexo.on('generateBefore', function () { | ||
hexo.on('generateBefore', function() { | ||
if (hexo.locals.get) { | ||
var data = hexo.locals.get('data'); | ||
|
||
/** | ||
* Merge configs from _data/next.yml into hexo.theme.config. | ||
* If `override`, configs in next.yml will rewrite configs in hexo.theme.config. | ||
* If next.yml not exists, merge all `theme_config.*` into hexo.theme.config. | ||
*/ | ||
if (data && data.next) { | ||
if (data.next.override) { | ||
hexo.theme.config = data.next; | ||
} else { | ||
merge(hexo.config, data.next); | ||
merge(hexo.theme.config, data.next); | ||
} | ||
/** | ||
* If next.yml not exists, then merge all `theme_config.*` | ||
* options from main Hexo config into hexo.theme.config. | ||
*/ | ||
} else { | ||
merge(hexo.theme.config, hexo.config.theme_config); | ||
} | ||
|
||
// Custom languages support. Introduced in NexT v6.3.0. | ||
if (data && data.languages) { | ||
var lang = this.config.language; | ||
var i18n = this.theme.i18n; | ||
|
||
var mergeLang = function(lang) { | ||
i18n.set(lang, merge(i18n.get([lang]), data.languages[lang])); | ||
}; | ||
|
||
if (Array.isArray(lang)) { | ||
for (var i = 0; i < lang.length; i++) { | ||
mergeLang(lang[i]); | ||
} | ||
} else { | ||
mergeLang(lang); | ||
} | ||
} | ||
} | ||
}); |