Files: 338e0ca3c8de6d685bca80161faf219c20acd76d / tmpl / page.part.js
1262 bytesRaw
1 | var head = require('./head.part') |
2 | var tabs = require('./tabs.part') |
3 | var leftnav = require('./leftnav.part') |
4 | var footer = require('./footer.part') |
5 | |
6 | module.exports = (opts) => { |
7 | |
8 | // render the hero |
9 | var hero = '' |
10 | if (opts.hero) { |
11 | hero = opts.hero |
12 | } else { |
13 | hero = `<div class="hero small"> |
14 | <h1><a href="/"><img src="/img/hermies-256.png"></a> Scuttlebot</h1> |
15 | </div>` |
16 | } |
17 | |
18 | // pick the navs |
19 | var tabFn = tabs[opts.section || 'docs'] || ()=>`` |
20 | var leftnavFn = leftnav[opts.tab || 'basics'] |
21 | |
22 | // next and see-also |
23 | var seeAlso = '', next = '' |
24 | if (opts.seeAlso) |
25 | seeAlso = `<ul class="see-also">` + opts.seeAlso.map(item => `<li><a href="${item[0]}">${item[1]}</a></li>`).join('') + `</ul>` |
26 | if (opts.next) |
27 | next = `<p class="next"><a href="${opts.next[0]}">${opts.next[1]}</a></p>` |
28 | |
29 | // render the page |
30 | return `<html> |
31 | ${head({ title: opts.title })} |
32 | <body> |
33 | ${hero} |
34 | ${tabs.sections(opts.section)} |
35 | ${tabFn(opts.tab)} |
36 | <div class="nav-content-unit ${!leftnavFn?'nonav':''}"> |
37 | ${leftnavFn ? leftnavFn(opts.path) : ''} |
38 | <div class="content"> |
39 | ${opts.content} |
40 | ${seeAlso} |
41 | ${next} |
42 | </div> |
43 | </div> |
44 | ${footer(opts.path)} |
45 | </body> |
46 | </html>` |
47 | } |
Built with git-ssb-web