Last active
April 3, 2018 16:24
-
-
Save zeke/b4477fa51af41ed5149e81338382d14c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio') | |
const i18n = require('..') | |
const locales = Object.keys(i18n.locales) | |
function getNav(locale) { | |
const docs = i18n.docs[locale] | |
const readme = docs['/docs/README'] | |
const html = readme.sections.map(section => section.html).join('\n') | |
const $ = cheerio.load(html) | |
const startHeading = $('h2')[1] | |
const listItems = $(startHeading).next('ul').html() | |
const toc = `<ul>${listItems}</ul>` | |
console.log(toc) | |
return toc | |
} | |
navs = locales.map(locale => { | |
return getNav(locales) | |
}) | |
i18n.navs = navs | |
fs.writeFileSync( | |
path.join(__dirname, '../index.json'), | |
JSON.stringify(i18n, null, 2) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment