toc fixes and improvement

- close #7
- close #8
This commit is contained in:
Kim, Jimin 2021-12-19 20:09:14 +09:00
parent ffd0a194de
commit e838ac59f7
6 changed files with 24 additions and 51 deletions

View file

@ -1,11 +1,10 @@
import fs from "fs"
import readTimeEstimate from "read-time-estimate" // post read time estimation
import matter from "gray-matter" // parse markdown metadata
import toc from "markdown-toc" // table of contents generation
import { JSDOM } from "jsdom" // HTML DOM parsing
import { nthIndex, path2FileOrFolderName, path2URL, writeToJSON } from "./util"
import parseMarkdown from "./parseMarkdown"
import parseMarkdown, { generateToc } from "./parseMarkdown"
import { contentDirectoryPath } from "./config"
import { addDocument } from "./searchIndex"
@ -186,7 +185,7 @@ function parsePost(data: DataToPass): void {
`${contentDirectoryPath}${urlPath}.json`,
JSON.stringify({
content: markdownData.content,
toc: toc(markdownRaw).json,
toc: generateToc(markdownRaw),
})
)
}
@ -294,7 +293,7 @@ function parseSeries(data: DataToPass): void {
`${contentDirectoryPath}${urlPath}.json`,
JSON.stringify({
content: markdownData.content,
toc: toc(markdownRaw).json,
toc: generateToc(markdownRaw),
})
)
}