Skip to content

Commit b2f7ec3

Browse files
committed
feat: 完善url迁移map
1 parent 9a5ea08 commit b2f7ec3

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

migration/index.mjs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import fs from 'node:fs';
2-
import path from 'node:path';
3-
41
import urlMap from './url-map.json' with { type: 'json' };
52

63
function normalizeUrl(url) {
@@ -21,18 +18,3 @@ export function getRedirects() {
2118
});
2219
return ret;
2320
}
24-
25-
function processJson() {
26-
const newObj = {};
27-
Object.entries(urlMap).forEach(([key, value]) => {
28-
// 将key中 post/* 变成 *
29-
newObj[key.replace('posts/', '')] = value;
30-
});
31-
// In ES modules, use import.meta.url instead of __dirname
32-
const __filename = new URL(import.meta.url).pathname;
33-
const __dirname = path.dirname(__filename);
34-
fs.writeFileSync(path.join(__dirname, 'url-map.json'), JSON.stringify(newObj, null, 2));
35-
}
36-
37-
processJson();
38-
console.log(getRedirects());

migration/url-map.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2+
"nvm-auto-switch": ["/blog/nvm-auto-switch", "/nvm-auto-switch"],
3+
"my-ai-tools-recommendation": ["/blog/my-ai-tools-recommendation", "/my-ai-tools-recommendation"],
4+
"module-for-browsers": ["/blog/module-for-browsers", "/module-for-browsers"],
5+
"all-about-dts": ["/blog/all-about-dts", "/all-about-dts"],
6+
"vscode-profile": ["/blog/vscode-profile", "/vscode-profile"],
7+
"my-brand-new-blog-system": ["/blog/my-brand-new-blog-system", "/my-brand-new-blog-system"],
8+
"arc-browser-alternative": ["/blog/arc-browser-alternative", "/arc-browser-alternative"],
29
"blog-solution": [
310
"2023/04/22/Development/blog-solution",
411
"post/development/blog-solution",

0 commit comments

Comments
 (0)