// `examples` is an object, mapping language->example module.exports.code = examples => { return `
${ Object.keys(examples).sort(langPrioritySort).map(lang => `
${lang}
`).join('') }
${ Object.keys(examples).sort(langPrioritySort).map(lang => `
${cleanupCode(examples[lang])}
`).join('') }
` } module.exports.tableOfContents = items => { items = items .map(item => [item.children[0].url, item.children[1].value]) .filter(item => item[0] && item[1]) return `
Jump to...
` } // enforce an order to the language tabs function langPrioritySort (a, b) { if (b == 'js' && a != 'js') return 1 return -1 } // do some cleanup on the code function cleanupCode (str) { return str.trim() }