From ca38c7c3deae963b7c13ae4e54a8e85b5b8650fd Mon Sep 17 00:00:00 2001 From: guobaoyang Date: Mon, 24 Dec 2018 16:44:59 +0800 Subject: [PATCH] fix(asset-id): Change source config,the source assets folder can't be generated fix #3398 --- lib/plugins/processor/asset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/processor/asset.js b/lib/plugins/processor/asset.js index 29b3259204..ee39ade154 100644 --- a/lib/plugins/processor/asset.js +++ b/lib/plugins/processor/asset.js @@ -3,7 +3,7 @@ const common = require('./common'); const Promise = require('bluebird'); const yfm = require('hexo-front-matter'); -const { extname } = require('path'); +const { extname, relative } = require('path'); const { Pattern } = require('hexo-util'); module.exports = ctx => { @@ -84,7 +84,7 @@ module.exports = ctx => { } function processAsset(file) { - const id = file.source.substring(ctx.base_dir.length).replace(/\\/g, '/'); + const id = relative(ctx.base_dir, file.source).replace(/\\/g, '/'); const Asset = ctx.model('Asset'); const doc = Asset.findById(id);