Update /my_account/index.html.jst to latest way, minor consistency changes in /my_acc...
[ndcode_site.git] / _lib / post.jst
1 let assert = require('assert')
2
3 return async (env, head, body, scripts) => {
4   let breadcrumbs = await _require('/_lib/breadcrumbs.jst')
5   let navbar = await _require('/_lib/navbar.jst')
6
7   await navbar(
8     env,
9     head,
10     // body
11     async _out => {
12       await breadcrumbs(env, _out)
13
14       // extract second-level directory name
15       assert(env.parsed_url.pathname.slice(0, 6) === '/blog/')
16       let index = env.parsed_url.pathname.indexOf('/', 6)
17       let dir = index === -1 ? '' : env.parsed_url.pathname.slice(6, index)
18
19       // load article data
20       let menu = await env.site.get_menu('/blog/_menu.json')
21       let article = menu.entries[menu.index[dir]]
22
23       div.row.mb-3 {
24         div.col-sm-12 {
25           img.img-responsive(src=article.image || 'image.jpg') {}
26         }
27       }
28
29       h3 {`${article.description}—by ${article.author}`}
30
31       await body(_out)
32     },
33     scripts
34   )
35 }