Skip to content

Commit 4912355

Browse files
author
chenliangzihao
committed
chore: fix config
1 parent 81a0c06 commit 4912355

File tree

3 files changed

+148
-105
lines changed

3 files changed

+148
-105
lines changed

migration/index.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import urlMap from './url-map.json' with { type: 'json' }
1+
import urlMap from './url-map.json' with { type: 'json' };
22

33
function normalizeUrl(url) {
4-
return `/${url}`
4+
return url.startsWith('/') ? url : `/${url}`;
55
}
66

77
/**
88
* Returns the redirects for the site.
99
* @returns {Record<string, import('astro').RedirectConfig>}
1010
*/
1111
export function getRedirects() {
12-
const ret = {}
13-
Object.keys(urlMap).forEach(key => {
14-
const aliases = urlMap[key].map(normalizeUrl)
15-
aliases.forEach(alias => {
16-
ret[alias] = normalizeUrl(key)
17-
})
18-
})
19-
return ret
12+
const ret = {};
13+
Object.keys(urlMap).forEach((key) => {
14+
const aliases = urlMap[key].map(normalizeUrl);
15+
aliases.forEach((alias) => {
16+
ret[alias] = normalizeUrl(key);
17+
});
18+
});
19+
return ret;
2020
}

migration/url-map.json

Lines changed: 100 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,194 @@
11
{
22
"posts/blog-solution": [
33
"2023/04/22/Development/blog-solution",
4-
"post/development/blog-solution"
4+
"post/development/blog-solution",
5+
"/blog-solution",
6+
"/blog/blog-solution"
57
],
68
"posts/bun-hands-on": [
79
"2023/10/24/Development/bun-hands-on",
8-
"post/development/bun-hands-on"
10+
"post/development/bun-hands-on",
11+
"/bun-hands-on",
12+
"/blog/bun-hands-on"
913
],
1014
"posts/covariant-and-contravarirant": [
1115
"2023/01/24/Development/covariant-and-contravarirant",
12-
"post/development/covariant-and-contravarirant"
16+
"post/development/covariant-and-contravarirant",
17+
"/covariant-and-contravarirant",
18+
"/blog/covariant-and-contravarirant"
1319
],
1420
"posts/deep-dive-react-hooks": [
1521
"2023/06/1/Development/deep-dive-react-hooks",
16-
"post/development/deep-dive-react-hooks"
22+
"post/development/deep-dive-react-hooks",
23+
"/deep-dive-react-hooks",
24+
"/blog/deep-dive-react-hooks"
1725
],
1826
"posts/deep-dive-react-redux": [
1927
"2023/08/14/Development/deep-dive-react-redux",
20-
"post/development/deep-dive-react-redux"
28+
"post/development/deep-dive-react-redux",
29+
"/deep-dive-react-redux",
30+
"/blog/deep-dive-react-redux"
2131
],
2232
"posts/do-u-need-memo-and-callback": [
2333
"2023/08/24/Development/do-u-need-memo-and-callback",
24-
"post/development/do-u-need-memo-and-callback"
25-
],
26-
"posts/edm": [
27-
"2023/03/20/Development/edm",
28-
"post/development/edm"
34+
"post/development/do-u-need-memo-and-callback",
35+
"/do-u-need-memo-and-callback",
36+
"/blog/do-u-need-memo-and-callback"
2937
],
38+
"posts/edm": ["2023/03/20/Development/edm", "post/development/edm", "/edm", "/blog/edm"],
3039
"posts/front-end-without-toolchain": [
3140
"2024/03/30/Development/front-end-without-toolchain",
32-
"post/development/front-end-without-toolchain"
41+
"post/development/front-end-without-toolchain",
42+
"/front-end-without-toolchain",
43+
"/blog/front-end-without-toolchain"
3344
],
3445
"posts/hands-on-docker": [
3546
"2023/07/11/Development/hands-on-docker",
36-
"post/development/hands-on-docker"
47+
"post/development/hands-on-docker",
48+
"/hands-on-docker",
49+
"/blog/hands-on-docker"
3750
],
3851
"posts/how-node-resolve-modules": [
3952
"2024/02/18/Development/how-node-resolve-modules",
40-
"post/development/how-node-resolve-modules"
53+
"post/development/how-node-resolve-modules",
54+
"/how-node-resolve-modules",
55+
"/blog/how-node-resolve-modules"
4156
],
4257
"posts/html-form": [
4358
"2023/05/31/Development/html-form",
44-
"post/development/html-form"
59+
"post/development/html-form",
60+
"/html-form",
61+
"/blog/html-form"
4562
],
4663
"posts/javascript-fundamentals": [
4764
"2023/05/16/Development/javascript-fundamentals",
48-
"post/development/javascript-fundamentals"
65+
"post/development/javascript-fundamentals",
66+
"/javascript-fundamentals",
67+
"/blog/javascript-fundamentals"
4968
],
5069
"posts/js-debounce-and-throttle": [
5170
"2023/05/24/Development/js-debounce-and-throttle",
52-
"post/development/js-debounce-and-throttle"
71+
"post/development/js-debounce-and-throttle",
72+
"/js-debounce-and-throttle",
73+
"/blog/js-debounce-and-throttle"
5374
],
5475
"posts/js-event-loop": [
5576
"2023/04/26/Development/js-event-loop",
56-
"post/development/js-event-loop"
77+
"post/development/js-event-loop",
78+
"/js-event-loop",
79+
"/blog/js-event-loop"
5780
],
5881
"posts/microservice-hands-on": [
5982
"2023/05/25/Development/microservice-hands-on",
60-
"post/development/microservice-hands-on"
83+
"post/development/microservice-hands-on",
84+
"/microservice-hands-on",
85+
"/blog/microservice-hands-on"
6186
],
6287
"posts/mobile-web-dev": [
6388
"2023/08/6/Development/mobile-web-dev",
64-
"post/development/mobile-web-dev"
65-
],
66-
"posts/monorepo": [
67-
"2023/05/26/Development/monorepo",
68-
"post/development/monorepo"
89+
"post/development/mobile-web-dev",
90+
"/mobile-web-dev",
91+
"/blog/mobile-web-dev"
6992
],
93+
"posts/monorepo": ["2023/05/26/Development/monorepo", "post/development/monorepo", "/monorepo", "/blog/monorepo"],
7094
"posts/npm-peer-dependency": [
7195
"2023/05/24/Development/npm-peer-dependency",
72-
"post/development/npm-peer-dependency"
96+
"post/development/npm-peer-dependency",
97+
"/npm-peer-dependency",
98+
"/blog/npm-peer-dependency"
7399
],
74100
"posts/network-fundamentals": [
75101
"2023/05/18/Development/network-fundamentals",
76-
"post/development/network-fundamentals"
102+
"post/development/network-fundamentals",
103+
"/network-fundamentals",
104+
"/blog/network-fundamentals"
77105
],
78106
"posts/personal-review-fe-in-2023": [
79107
"2024/01/30/Development/personal-review-fe-in-2023",
80-
"post/development/personal-review-fe-in-2023"
81-
],
82-
"posts/pnpm": [
83-
"2023/06/9/Development/pnpm",
84-
"post/development/pnpm"
85-
],
86-
"posts/npm": [
87-
"2023/06/6/Development/npm",
88-
"post/development/npm"
108+
"post/development/personal-review-fe-in-2023",
109+
"/personal-review-fe-in-2023",
110+
"/blog/personal-review-fe-in-2023"
89111
],
112+
"posts/pnpm": ["2023/06/9/Development/pnpm", "post/development/pnpm", "/pnpm", "/blog/pnpm"],
113+
"posts/npm": ["2023/06/6/Development/npm", "post/development/npm", "/npm", "/blog/npm"],
90114
"posts/ref-callback": [
91115
"2023/09/4/Development/ref-callback",
92-
"post/development/ref-callback"
116+
"post/development/ref-callback",
117+
"/ref-callback",
118+
"/blog/ref-callback"
93119
],
94120
"posts/shell-shebang": [
95121
"2023/07/13/Development/shell-shebang",
96-
"post/development/shell-shebang"
122+
"post/development/shell-shebang",
123+
"/shell-shebang",
124+
"/blog/shell-shebang"
97125
],
98126
"posts/ssr-from-scratch": [
99127
"2023/09/21/Development/ssr-from-scratch",
100-
"post/development/ssr-from-scratch"
128+
"post/development/ssr-from-scratch",
129+
"/ssr-from-scratch",
130+
"/blog/ssr-from-scratch"
101131
],
102132
"posts/what-is-best-leetcode-lang": [
103133
"2023/04/12/Development/what-is-best-leetcode-lang",
104-
"post/development/what-is-best-leetcode-lang"
134+
"post/development/what-is-best-leetcode-lang",
135+
"/what-is-best-leetcode-lang",
136+
"/blog/what-is-best-leetcode-lang"
105137
],
106138
"posts/web-socket": [
107139
"2023/07/9/Development/web-socket",
108-
"post/development/web-socket"
140+
"post/development/web-socket",
141+
"/web-socket",
142+
"/blog/web-socket"
109143
],
110144
"posts/yarn-berry": [
111145
"2023/06/8/Development/yarn-berry",
112-
"post/development/yarn-berry"
146+
"post/development/yarn-berry",
147+
"/yarn-berry",
148+
"/blog/yarn-berry"
113149
],
114150
"posts/评好逸恶劳大学生": [
115151
"2022/01/28/Life/评好逸恶劳大学生",
116-
"post/life/评好逸恶劳大学生"
117-
],
118-
"posts/20岁随笔": [
119-
"2021/12/2/Life/20岁随笔",
120-
"post/life/20岁随笔"
152+
"post/life/评好逸恶劳大学生",
153+
"/评好逸恶劳大学生",
154+
"/blog/评好逸恶劳大学生"
121155
],
156+
"posts/20岁随笔": ["2021/12/2/Life/20岁随笔", "post/life/20岁随笔", "/20岁随笔", "/blog/20岁随笔"],
122157
"posts/permutation": [
123158
"2023/04/19/Research/permutation",
124-
"post/research/permutation"
125-
],
126-
"posts/KeePass": [
127-
"2023/05/23/Technology/KeePass",
128-
"post/technology/keepass"
159+
"post/research/permutation",
160+
"/permutation",
161+
"/blog/permutation"
129162
],
163+
"posts/KeePass": ["2023/05/23/Technology/KeePass", "post/technology/keepass", "/KeePass", "/blog/KeePass"],
130164
"posts/hands-on-csx": [
131165
"2023/04/11/Technology/hands-on-csx",
132-
"post/technology/hands-on-csx"
166+
"post/technology/hands-on-csx",
167+
"/hands-on-csx",
168+
"/blog/hands-on-csx"
133169
],
134170
"posts/python-dev-env": [
135171
"2023/07/9/Technology/python-dev-env",
136-
"post/technology/python-dev-env"
172+
"post/technology/python-dev-env",
173+
"/python-dev-env",
174+
"/blog/python-dev-env"
137175
],
138176
"posts/reshaper-alternatives": [
139177
"2023/02/14/Technology/reshaper-alternatives",
140-
"post/technology/reshaper-alternatives"
178+
"post/technology/reshaper-alternatives",
179+
"/reshaper-alternatives",
180+
"/blog/reshaper-alternatives"
141181
],
142182
"posts/shell-optimize": [
143183
"2023/08/6/Technology/shell-optimize",
144-
"post/technology/shell-optimize"
184+
"post/technology/shell-optimize",
185+
"/shell-optimize",
186+
"/blog/shell-optimize"
145187
],
146188
"posts/win-dev-drive-hands-on": [
147189
"2023/11/15/Technology/win-dev-drive-hands-on",
148-
"post/technology/win-dev-drive-hands-on"
190+
"post/technology/win-dev-drive-hands-on",
191+
"/win-dev-drive-hands-on",
192+
"/blog/win-dev-drive-hands-on"
149193
]
150-
}
194+
}

0 commit comments

Comments
 (0)