1
0
mirror of synced 2025-12-21 02:46:50 -05:00

feedback on CodeQL docs formatting (#35668)

This commit is contained in:
Rachael Sewell
2023-03-17 12:01:46 -07:00
committed by GitHub
parent a14b94da02
commit d7ed88fd99
2 changed files with 21 additions and 8 deletions

View File

@@ -96,6 +96,11 @@ async function main() {
frontmatter.title = node.children[0].value
}
// The level 2 heading "Options" should be displayed as "Primary options"
if (node.depth === 2 && node.children[0].value === 'Options') {
node.children[0].value = 'Primary options'
}
// There are some headings that include a title followed by
// some markup that looks like
// {#options-to-configure-the-package-manager.}
@@ -254,9 +259,18 @@ async function main() {
await writeFile(targetFilename, matter.stringify(markdownContent, frontmatter))
}
// update index.md file
// create or update the index.md file
const indexFilepath = `${targetDirectory}/index.md`
const { data, content } = matter(await readFile(indexFilepath, 'utf-8'))
const { data, content } = existsSync(indexFilepath)
? matter(await readFile(indexFilepath, 'utf-8'))
: {
data: {
title: 'placeholder',
...frontmatterDefaults,
children: [],
},
content: '',
}
data.children = markdownFiles.map((file) => `/${path.basename(file, '.md')}`).sort()
await writeFile(indexFilepath, matter.stringify(content, data))
}