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);