Skip to content

Commit 216c5a6

Browse files
committed
fix: fixed chinese url of blog
1 parent ad212d1 commit 216c5a6

File tree

2 files changed

+2120
-2497
lines changed

2 files changed

+2120
-2497
lines changed

theme/plugins/blog/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
const { path, _ } = require('@micro-app/shared-utils');
22

3+
// fixed chinese path...
4+
const blogPluginUtil = require('@vuepress/plugin-blog/lib/node/util.js');
5+
const oldCurryFrontmatterHandler = blogPluginUtil.curryFrontmatterHandler;
6+
const FIXED_PATH = Symbol('FIXED_PATH');
7+
blogPluginUtil.curryFrontmatterHandler = (scope, map, _path) => {
8+
const fn = oldCurryFrontmatterHandler(scope, map, _path)
9+
return (key, pageKey) => {
10+
const r = fn(key, pageKey);
11+
if (key) {
12+
if (map[key] && map[key].path && !map[key][FIXED_PATH]) {
13+
// map[key].path = `${path}${key}/`;
14+
map[key].path = encodeURI(`${_path}${key}/`); // fixed path
15+
map[key][FIXED_PATH] = true;
16+
}
17+
}
18+
return r;
19+
};
20+
};
21+
322
// 初始化默认值
423
const initBlogConfig = require('./init');
524

0 commit comments

Comments
 (0)