From 6c88c98214765112d148850a646ddca379fcdcfe Mon Sep 17 00:00:00 2001 From: "7ym0n.q6e" <7ym0n@users.noreply.github.com> Date: Sat, 15 Sep 2018 13:43:39 +0800 Subject: [PATCH] fixd images path error add hexo version > 3 local images path wrong --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 59da07d..dd8d263 100644 --- a/index.js +++ b/index.js @@ -6,11 +6,15 @@ function getPosition(str, m, i) { return str.split(m, i).join(m).length; } +var version = String(hexo.version).split('.'); hexo.extend.filter.register('after_post_render', function(data){ var config = hexo.config; if(config.post_asset_folder){ - var link = data.permalink; - var beginPos = getPosition(link, '/', 3) + 1; + var link = data.permalink; + if(version.length > 0 && Number(version[0]) == 3) + var beginPos = getPosition(link, '/', 1) + 1; + else + var beginPos = getPosition(link, '/', 3) + 1; // In hexo 3.1.1, the permalink of "about" page is like ".../about/index.html". var endPos = link.lastIndexOf('/') + 1; link = link.substring(beginPos, endPos);