Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
feat: add hexo.config.root support
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazeyu committed Feb 19, 2018
1 parent 9b7a456 commit 25ad2fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
// 'extends': 'eslint:all',
'extends': 'eslint:recommended',
'parserOptions': {
'sourceType': 'module',
'sourceType': 'script',
},
'rules': {
'indent': [
Expand Down
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const coreScriptName = manifest['main.js'];
const thisPkgInfo = require('./package');
const coreJsDepVer = thisPkgInfo.dependencies['live2d-widget'];

const onSiteRootPath = '/live2dw/';
const blogRoot = hexo.config.root || '/';
const onSiteRootPath = `live2dw/`;
const onSiteJsPath = `${onSiteRootPath}lib/`;
const onSiteModelPath = `${onSiteRootPath}assets/`;

Expand Down Expand Up @@ -52,7 +53,7 @@ function getScriptURL (scriptFrom) {
const scriptGenerators = buildGeneratorsFromManifest(manifest, path.dirname(mainfestPath), onSiteJsPath);
const useHash = getFileMD5(path.resolve(path.dirname(mainfestPath), coreScriptName));
generators.push(...scriptGenerators);
return `${url.resolve(onSiteJsPath, coreScriptName)}?${useHash}`;
return `${blogRoot}${url.resolve(onSiteJsPath, coreScriptName)}?${useHash}`;

}
case 'jsdelivr':
Expand Down Expand Up @@ -98,7 +99,7 @@ if (config.enable) {
modelGenerators,
'modelJsonUrl': pkgModelJsonUrl,
} = loadModelFrom(tryPath, onSiteModelPath);
modelJsonUrl = pkgModelJsonUrl;
modelJsonUrl = `${blogRoot}${pkgModelJsonUrl}`;
generators.push(...modelGenerators);
print.log(`Loaded model from live2d_models folder(2), '${url.parse(modelJsonUrl).pathname}' from '${tryPath}'`);

Expand All @@ -115,7 +116,7 @@ if (config.enable) {
modelGenerators,
'modelJsonUrl': pkgModelJsonUrl,
} = loadModelFrom(tryPath, onSiteModelPath);
modelJsonUrl = pkgModelJsonUrl;
modelJsonUrl = `${blogRoot}${pkgModelJsonUrl}`;
generators.push(...modelGenerators);
print.log(`Loaded model from hexo base releated path(3), '${url.parse(modelJsonUrl).pathname}' from '${tryPath}'`);

Expand All @@ -142,7 +143,7 @@ if (config.enable) {
modelGenerators,
'modelJsonUrl': pkgModelJsonUrl,
} = loadModelFrom(assetsDir, onSiteModelPath);
modelJsonUrl = pkgModelJsonUrl;
modelJsonUrl = `${blogRoot}${pkgModelJsonUrl}`;
generators.push(...modelGenerators);
print.log(`Loaded model from npm-module(1), ${packageJsonObj.name}@${packageJsonObj.version} from '${assetsDir}'`);

Expand Down

0 comments on commit 25ad2fe

Please sign in to comment.