Skip to content

Commit

Permalink
Merge pull request #157 from dalecgu/forsigner/dev
Browse files Browse the repository at this point in the history
Support user config by using data files 通过使用Hexo3的特性Data Files支持本地修改主题的配置
  • Loading branch information
leenxyz committed Oct 8, 2019
2 parents 378d3d7 + 3404648 commit b2340e4
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 36 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ init_page_content: HOME_NAV # HOME_NAV | POST
# 第三方服务
# =========================================================
# Stats
google_analytics:
google_analytics: UA-38189205-1
baidu_analytics: 57e94d016e201fba3603a8a2b0263af0

# Comment service
Expand Down
3 changes: 2 additions & 1 deletion layout/_partial/component/gitalk.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const gitalk = new Gitalk({
owner: '<%= theme.gitalk.owner %>',
// 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
// 50个字符串则会报错.
id: location.pathname.split('/').pop().substring(0, 49),
// id: location.pathname.split('/').pop().substring(0, 49),
id: location.pathname,
admin: ['<%= theme.gitalk.admin %>'],
// facebook-like distraction free mode
distractionFreeMode: false
Expand Down
50 changes: 50 additions & 0 deletions scripts/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

/* global hexo */

/**
* Merge configs in _data/fexo.yml into hexo.theme.
* Note: configs in _data/fexo.yml will override configs in hexo.theme.
*/
hexo.on('generateBefore', function () {
var data = hexo.locals.get('data');
data && data.fexo && assign(hexo.theme.config, data.fexo);
});

// https://github.com/sindresorhus/object-assign
function assign(target, source) {
var from;
var keys;
var to = toObject(target);

for (var s = 1; s < arguments.length; s++) {
from = arguments[s];
keys = ownEnumerableKeys(Object(from));

for (var i = 0; i < keys.length; i++) {
to[keys[i]] = from[keys[i]];
}
}

return to;
}

function toObject(val) {
if (val == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}

return Object(val);
}

function ownEnumerableKeys(obj) {
var keys = Object.getOwnPropertyNames(obj);

if (Object.getOwnPropertySymbols) {
keys = keys.concat(Object.getOwnPropertySymbols(obj));
}

return keys.filter(function (key) {
return Object.prototype.propertyIsEnumerable.call(obj, key);
});
}
80 changes: 46 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ are-we-there-yet@~1.1.2:

argparse@^1.0.7:
version "1.0.10"
resolved "http://registry.npm.taobao.org/argparse/download/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"

Expand Down Expand Up @@ -292,7 +292,7 @@ babylon@^6.0.18, babylon@^6.18.0:

balanced-match@^1.0.0:
version "1.0.0"
resolved "http://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=

base@^0.11.1:
Expand Down Expand Up @@ -322,7 +322,7 @@ beeper@^1.0.0:

block-stream@*:
version "0.0.9"
resolved "http://registry.npm.taobao.org/block-stream/download/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a"
resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a"
integrity sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=
dependencies:
inherits "~2.0.0"
Expand Down Expand Up @@ -578,7 +578,7 @@ component-emitter@^1.2.1:

concat-map@0.0.1:
version "0.0.1"
resolved "http://registry.npm.taobao.org/concat-map/download/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

concat-with-sourcemaps@^1.0.0:
Expand Down Expand Up @@ -865,8 +865,8 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:

esprima@^4.0.0:
version "4.0.1"
resolved "http://registry.npm.taobao.org/esprima/download/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==

esutils@^2.0.2:
version "2.0.2"
Expand Down Expand Up @@ -1045,13 +1045,13 @@ fragment-cache@^0.2.1:

fs.realpath@^1.0.0:
version "1.0.0"
resolved "http://registry.npm.taobao.org/fs.realpath/download/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

fstream@^1.0.0, fstream@^1.0.2:
version "1.0.11"
resolved "http://registry.npm.taobao.org/fstream/download/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171"
integrity sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=
fstream@^1.0.0, fstream@^1.0.12:
version "1.0.12"
resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045"
integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==
dependencies:
graceful-fs "^4.1.2"
inherits "~2.0.0"
Expand Down Expand Up @@ -1144,7 +1144,7 @@ glob@^4.3.1:
minimatch "^2.0.1"
once "^1.3.0"

glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.1:
glob@^7.0.0, glob@^7.0.3, glob@^7.1.2, glob@~7.1.1:
version "7.1.3"
resolved "http://registry.npm.taobao.org/glob/download/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
integrity sha1-OWCDLT8VdBCDQtr9OmezMsCWnfE=
Expand All @@ -1156,6 +1156,18 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.1.3:
version "7.1.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255"
integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@~3.1.21:
version "3.1.21"
resolved "http://registry.npm.taobao.org/glob/download/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd"
Expand Down Expand Up @@ -1217,8 +1229,8 @@ glogg@^1.0.0:

graceful-fs@4.X, graceful-fs@^4.1.2:
version "4.1.15"
resolved "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
integrity sha1-/7cD4QZuig7qpMi4C6klPu77+wA=
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==

graceful-fs@^3.0.0:
version "3.0.11"
Expand Down Expand Up @@ -1477,7 +1489,7 @@ indent-string@^2.1.0:

inflight@^1.0.4:
version "1.0.6"
resolved "http://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
Expand Down Expand Up @@ -1725,9 +1737,9 @@ js-tokens@^3.0.2:
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.4.3:
version "3.12.0"
resolved "http://registry.npm.taobao.org/js-yaml/download/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
integrity sha1-6u1lbsg0TxD1J8a/obbiJE3hZ9E=
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
Expand Down Expand Up @@ -2201,8 +2213,8 @@ minimatch@^2.0.1:

minimatch@^3.0.4, minimatch@~3.0.2:
version "3.0.4"
resolved "http://registry.npm.taobao.org/minimatch/download/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"

Expand All @@ -2216,7 +2228,7 @@ minimatch@~0.2.11:

minimist@0.0.8:
version "0.0.8"
resolved "http://registry.npm.taobao.org/minimist/download/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=

minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0:
Expand Down Expand Up @@ -2440,7 +2452,7 @@ object.pick@^1.2.0, object.pick@^1.3.0:

once@^1.3.0:
version "1.4.0"
resolved "http://registry.npm.taobao.org/once/download/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
Expand Down Expand Up @@ -2526,7 +2538,7 @@ path-exists@^2.0.0:

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "http://registry.npm.taobao.org/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=

path-parse@^1.0.5:
Expand Down Expand Up @@ -2870,11 +2882,11 @@ right-align@^0.1.1:
align-text "^0.1.1"

rimraf@2:
version "2.6.2"
resolved "http://registry.npm.taobao.org/rimraf/download/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
integrity sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
dependencies:
glob "^7.0.5"
glob "^7.1.3"

safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
Expand Down Expand Up @@ -3069,7 +3081,7 @@ split-string@^3.0.1, split-string@^3.0.2:

sprintf-js@~1.0.2:
version "1.0.3"
resolved "http://registry.npm.taobao.org/sprintf-js/download/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

sshpk@^1.7.0:
Expand Down Expand Up @@ -3192,12 +3204,12 @@ supports-color@^5.3.0, supports-color@^5.4.0:
has-flag "^3.0.0"

tar@^2.0.0:
version "2.2.1"
resolved "http://registry.npm.taobao.org/tar/download/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1"
integrity sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=
version "2.2.2"
resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.2.tgz#0ca8848562c7299b8b446ff6a4d60cdbb23edc40"
integrity sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==
dependencies:
block-stream "*"
fstream "^1.0.2"
fstream "^1.0.12"
inherits "2"

through2@2.X, through2@^2.0.0, through2@^2.0.3, through2@~2.0.0:
Expand Down Expand Up @@ -3492,7 +3504,7 @@ wrap-ansi@^2.0.0:

wrappy@1:
version "1.0.2"
resolved "http://registry.npm.taobao.org/wrappy/download/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

"xtend@>=4.0.0 <4.1.0-0", xtend@~4.0.1:
Expand Down

0 comments on commit b2340e4

Please sign in to comment.