64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const footer = require('./htmlFooter')
|
|
|
|
module.exports = (title, content, data) => {
|
|
|
|
const encodedTitle = encodeURIComponent(title)
|
|
|
|
let commentScript = ' <!-- no comment toot configured -->'
|
|
if (data.metadata) {
|
|
const meta = data.metadata
|
|
const commentOptions = JSON.stringify(meta)
|
|
commentScript = ` <div class="footer" id="comments">
|
|
<a href="../cgi-bin/comments.html.cgi?rootToot=${meta.rootToot}&tootSource=${meta.tootSource}&title=${encodedTitle}&backlink=${data.entryRelativeUrl}">Comments</a></p>
|
|
</div>
|
|
<script src="../comments.js"></script>
|
|
<script>
|
|
MYCROBE.comments(document.getElementById('comments'), ${commentOptions}, '${encodedTitle}')
|
|
</script>`
|
|
}
|
|
|
|
let page = `
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>${title}</title>
|
|
<link href="../styles.css" rel="stylesheet">
|
|
<link rel="alternate" type="application/atom+xml" title="Feed for mycrobe's Journal" href="../feed.xml">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="generator" content="CMS ETL BBQ; https://tildegit.org/mycrobe/cmsetlbbq/issues/19" />
|
|
</head>
|
|
<body>
|
|
<ul class="nav">
|
|
<li><a class="home" href="..">Journal Home</a></li>`
|
|
|
|
if (data.prev) {
|
|
page += `<li><a class="prev" href="${data.prev}">Previous</a></li>`
|
|
}
|
|
|
|
if (data.next) {
|
|
page += `<li><a class="next" href="${data.next}">Next</a></li>`
|
|
}
|
|
|
|
page += `
|
|
</ul>
|
|
<div class="heading">
|
|
<h1 class="title">${title}</h1>
|
|
<ul class="tags">
|
|
${data.tags.map(tag => `<li><a href="../tags/${tag}/">${tag}</a></li>`).join('')}
|
|
</ul>
|
|
<div class="metadata">
|
|
<div class="date">${data.date}</div><div class="location">${data.location || ''}</div>
|
|
</div>
|
|
</div>
|
|
<div class="content">
|
|
${content}
|
|
</div>
|
|
${commentScript}
|
|
${footer('..')}
|
|
</body>
|
|
`
|
|
|
|
return page
|
|
}
|