1
0
mirror of synced 2025-12-22 03:16:52 -05:00

update scripts to fix a few bugs

This commit is contained in:
Sarah Schneider
2021-04-20 12:49:57 -04:00
parent ebc2c11013
commit 5e2a1b51c8
2 changed files with 13 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
const fs = require('fs')
const path = require('path')
const walk = require('walk-sync')
const stripHtmlComments = require('strip-html-comments')
const languages = require('../../lib/languages')
const frontmatter = require('../../lib/read-frontmatter')
const addRedirectToFrontmatter = require('../../lib/redirects/add-redirect-to-frontmatter')
@@ -26,6 +27,10 @@ const categoryIndexFiles = fullDirectoryPaths.map(fullDirectoryPath => walk(full
categoryIndexFiles.forEach(categoryIndexFile => {
let categoryIndexContent = fs.readFileSync(categoryIndexFile, 'utf8')
if (categoryIndexFile.endsWith('github/getting-started-with-github/index.md')) {
categoryIndexContent = stripHtmlComments(categoryIndexContent.replace(/\n<!--/g, '<!--'))
}
// find array of TOC link strings
const rawItems = categoryIndexContent.match(linksArray)
if (!rawItems || !rawItems[0].includes('topic_link_in_list')) return