mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
chore(v2): upgrade devDependencies (#2538)
* chore(v2): upgrade devDependencies * chore(v2): upgrade devDependencies * chore: prettier
This commit is contained in:
parent
ea8c916528
commit
b07507c9cc
148 changed files with 2385 additions and 1975 deletions
|
@ -20,7 +20,7 @@ const tocRegex = new RegExp('<AUTOGENERATED_TABLE_OF_CONTENTS>', 'i');
|
|||
*
|
||||
*/
|
||||
function getTOC(content, headingTags = 'h2', subHeadingTags = 'h3') {
|
||||
const tagToLevel = tag => Number(tag.slice(1));
|
||||
const tagToLevel = (tag) => Number(tag.slice(1));
|
||||
const headingLevels = [].concat(headingTags).map(tagToLevel);
|
||||
const subHeadingLevels = subHeadingTags
|
||||
? [].concat(subHeadingTags).map(tagToLevel)
|
||||
|
@ -35,7 +35,7 @@ function getTOC(content, headingTags = 'h2', subHeadingTags = 'h3') {
|
|||
const slugger = new GithubSlugger();
|
||||
let current;
|
||||
|
||||
headings.forEach(heading => {
|
||||
headings.forEach((heading) => {
|
||||
const rawContent = heading.content;
|
||||
const rendered = md.renderInline(rawContent);
|
||||
|
||||
|
@ -68,8 +68,8 @@ function insertTOC(rawContent) {
|
|||
const filterRe = /^`[^`]*`/;
|
||||
const headers = getTOC(rawContent, 'h3', null);
|
||||
const tableOfContents = headers
|
||||
.filter(header => filterRe.test(header.rawContent))
|
||||
.map(header => ` - [${header.rawContent}](#${header.hashLink})`)
|
||||
.filter((header) => filterRe.test(header.rawContent))
|
||||
.map((header) => ` - [${header.rawContent}](#${header.hashLink})`)
|
||||
.join('\n');
|
||||
return rawContent.replace(tocRegex, tableOfContents);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue