Skip to content

Commit 2d59ed9

Browse files
feat(migrate): clean html more deeply before process and reformat before commit
1 parent a71cf5a commit 2d59ed9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

migrate/migrate-bot.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ async function fetchPageContent(
6969
const html = await response.text();
7070
const dom = new JSDOM(html);
7171
const contentElement = dom.window.document.querySelector("#mw-content-text");
72-
contentElement?.querySelector(".t-navbar")?.remove();
72+
73+
const selectorsToRemove = [
74+
".t-navbar",
75+
".t-example-live-link",
76+
"editsection",
77+
"#toc",
78+
];
79+
for (const selector of selectorsToRemove) {
80+
const elements = contentElement?.querySelectorAll(selector);
81+
elements?.forEach((el) => el.remove());
82+
}
7383
const headingElement = dom.window.document.querySelector("#firstHeading");
7484
if (!contentElement) {
7585
throw new Error("Could not find #mw-content-text");
@@ -423,7 +433,13 @@ async function main() {
423433
console.log(` 写入 ${filePath}`);
424434
await writeMDXFile(filePath, mdx, title);
425435

426-
console.log(` 尝试构建...`);
436+
console.log(` 重新格式化...`);
437+
spawnSync(`npm`, ["run", "format"], {
438+
stdio: "inherit",
439+
shell: true,
440+
});
441+
442+
console.log(` 构建...`);
427443
const res = spawnSync(`npm`, ["run", "build"], {
428444
stdio: "inherit",
429445
shell: true,

0 commit comments

Comments
 (0)