use comment instead of meta tag for _partial metadata

This commit is contained in:
caandt 2024-09-13 16:27:43 -05:00
parent 8e7c4b75ca
commit 04abd9f5b4
2 changed files with 4 additions and 2 deletions

View file

@ -67,7 +67,9 @@ def make_page(page, dest):
out = base.replace('{{ content }}', post.content).replace('{{ title }}', post['title']) #+ f' - {"&#x03BC.twoha.cc" if minimal else "u.twoha.cc"}')
path_write(dest, out)
if not minimal:
content = f'<meta name="metadata" content="{html.escape(json.dumps(post.metadata))}">\n{post.content}'
dump = json.dumps(post.metadata)
assert '-->' not in dump
content = f'<!--{dump}-->\n{post.content}'
path_write(outdir / '_partial' / dest.relative_to(outdir), content)
def main(_):

View file

@ -20,6 +20,7 @@ async function _loadContent(u, push=false) {
const r = await fetch(url);
if (r.ok) {
let t = await r.text();
let metadata = JSON.parse(t.substring(4, t.indexOf('-->\n')))
content.innerHTML = t;
if (push)
history.pushState('', '', u);
@ -31,7 +32,6 @@ async function _loadContent(u, push=false) {
s.appendChild(document.createTextNode(e.innerHTML));
e.parentNode.replaceChild(s, e);
});
let metadata = JSON.parse(document.querySelector('meta[name="metadata"]').content);
document.title = metadata.title + ' - u.twoha.cc';
currentPathname = p;
} else {