git ssb

2+

cel / scuttlebot.io



Tree: 86cfe7c6ec39c87ba43e41c3ed13c7902bf07fd8

Files: 86cfe7c6ec39c87ba43e41c3ed13c7902bf07fd8 / tmpl / com.part.js

696 bytesRaw
1
2// `examples` is an object, mapping language->example
3module.exports.code = examples => {
4 return `<div class="code-examples">
5 <div class="head">
6 ${ Object.keys(examples).sort(langPrioritySort).map(lang => `<div class="tab">${lang}</div>`).join('') }
7 </div>
8 <div class="body">
9 ${ Object.keys(examples).sort(langPrioritySort).map(lang => `<pre><code class="language-${lang}">${cleanupCode(examples[lang])}</code></pre>`).join('') }
10 </div>
11 </div>`
12}
13
14// enforce an order to the language tabs
15function langPrioritySort (a, b) {
16 if (b == 'js' && a != 'js')
17 return 1
18 return -1
19}
20
21// do some cleanup on the code
22function cleanupCode (str) {
23 return str.trim()
24}

Built with git-ssb-web