Skip to content

Commit

Permalink
fix: fixed chinese url of blog
Browse files Browse the repository at this point in the history
  • Loading branch information
zyao89 committed Sep 15, 2021
1 parent ad212d1 commit 216c5a6
Show file tree
Hide file tree
Showing 2 changed files with 2,120 additions and 2,497 deletions.
19 changes: 19 additions & 0 deletions theme/plugins/blog/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
const { path, _ } = require('@micro-app/shared-utils');

// fixed chinese path...
const blogPluginUtil = require('@vuepress/plugin-blog/lib/node/util.js');
const oldCurryFrontmatterHandler = blogPluginUtil.curryFrontmatterHandler;
const FIXED_PATH = Symbol('FIXED_PATH');
blogPluginUtil.curryFrontmatterHandler = (scope, map, _path) => {
const fn = oldCurryFrontmatterHandler(scope, map, _path)
return (key, pageKey) => {
const r = fn(key, pageKey);
if (key) {
if (map[key] && map[key].path && !map[key][FIXED_PATH]) {
// map[key].path = `${path}${key}/`;
map[key].path = encodeURI(`${_path}${key}/`); // fixed path
map[key][FIXED_PATH] = true;
}
}
return r;
};
};

// 初始化默认值
const initBlogConfig = require('./init');

Expand Down
Loading

0 comments on commit 216c5a6

Please sign in to comment.