oasis/src/pages/views/components/template.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-28 20:49:01 +00:00
'use strict'
const {
a,
body,
head,
html,
link,
meta,
nav,
2019-06-30 18:56:20 +00:00
main,
title
} = require('hyperaxe')
var doctypeString = '<!DOCTYPE html>'
const toAttributes = (obj) =>
Object.entries(obj).map(entry =>
`${entry[0]}=${entry[1]}`
).join(', ')
module.exports = (...elements) => {
const nodes =
html({ lang: 'en' },
head(
title('🏝️ Oasis'),
link({ rel: 'stylesheet', href: '/assets/style.css' }),
link({ rel: 'stylesheet', href: '/highlight/github.css' }),
meta({ name: 'description', content: 'friendly neighborhood scuttlebutt interface' }),
meta({ name: 'viewport', content: toAttributes({ width: 'device-width', 'initial-scale': 1 }) })
),
body(
nav(
a({ href: '/' }, 'home'),
2019-07-26 17:06:47 +00:00
a({ href: '/mentions' }, 'mentions'),
a({ href: '/profile' }, 'profile'),
a({ href: '/status' }, 'status'),
a({ href: 'https://github.com/fraction/oasis' }, 'source'),
a({ href: 'https://github.com/fraction/oasis/issues/new' }, 'help')
),
2019-06-30 18:56:20 +00:00
main({ id: 'content' }, ...elements)
)
)
const result = doctypeString + nodes.outerHTML
return result
}