parent
7479c1045c
commit
764b55045d
@ -89,12 +89,18 @@ export function create(str = '', options = {}) {
|
|||||||
if (!options.isHome) {
|
if (!options.isHome) {
|
||||||
const tocsMenus = getTocsTitleNode([...tocsData]);
|
const tocsMenus = getTocsTitleNode([...tocsData]);
|
||||||
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
|
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
|
||||||
tocsMenus.forEach((menu) => {
|
tocsMenus.forEach((menu, idx) => {
|
||||||
detailData.sections.push({
|
const level = menu?.properties['data-num'];
|
||||||
a: menu?.properties?.href,
|
if (idx + 1 === tocsMenus.length && level === 2) {
|
||||||
t: getCodeString(menu.children),
|
return;
|
||||||
l: menu?.properties['data-num'],
|
}
|
||||||
});
|
if (level < 4) {
|
||||||
|
detailData.sections.push({
|
||||||
|
a: menu?.properties?.href,
|
||||||
|
t: getCodeString(menu.children),
|
||||||
|
l: menu?.properties['data-num'],
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
node.children = tocsData;
|
node.children = tocsData;
|
||||||
|
@ -45,7 +45,9 @@ export async function createHTML(files = [], num = 0) {
|
|||||||
searchData[options.filename] = data;
|
searchData[options.filename] = data;
|
||||||
searchData.name = options.filename;
|
searchData.name = options.filename;
|
||||||
await fs.writeJSON(SEARCH_DATA_CACHE, searchData);
|
await fs.writeJSON(SEARCH_DATA_CACHE, searchData);
|
||||||
const resultSearchData = Object.keys({ ...searchData }).map((name) => searchData[name]);
|
const resultSearchData = Object.keys({ ...searchData })
|
||||||
|
.map((name) => searchData[name])
|
||||||
|
.filter((item) => typeof item !== 'string');
|
||||||
await fs.writeJSON(SEARCH_DATA, resultSearchData);
|
await fs.writeJSON(SEARCH_DATA, resultSearchData);
|
||||||
}
|
}
|
||||||
await fs.writeFile(outputHTMLPath, html);
|
await fs.writeFile(outputHTMLPath, html);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user