[upgrade] Abstract components on the page into subcomponents

This commit is contained in:
PrinOrange
2024-09-28 00:18:55 +08:00
parent f00a79fcf3
commit 959e513dcd
31 changed files with 508 additions and 374 deletions

View File

@@ -1,4 +1,4 @@
import type { TTOCItem } from "@/types/docs.type";
import type { TPostTOCItem } from "@/types/docs.type";
import { JSDOM } from "jsdom";
/**
@@ -10,7 +10,7 @@ import { JSDOM } from "jsdom";
export const makeTOCTree = (htmlCode: string) => {
const doc_dom = new JSDOM(htmlCode);
const all_headers = doc_dom.window.document.querySelectorAll("h1,h2,h3,h4,h5,h6");
const result: TTOCItem[] = [];
const result: TPostTOCItem[] = [];
for (let i = 0; i < all_headers.length; i++) {
const level = Number.parseInt(all_headers[i].tagName.replace("H", ""));
result.push({