minor tweaks to post page

This commit is contained in:
Satria 2026-05-28 20:35:11 +07:00
commit 550ce3dabc
6 changed files with 162 additions and 49 deletions

View file

@ -1,15 +1,16 @@
import { readdir } from "node:fs/promises";
import { YAML } from "bun";
import metadata from "./metadata.json";
import templateRaw from "./template.html" with { type: "text" };
import templateRaw from "./templates/post.html" with { type: "text" };
const templateStr = templateRaw as unknown as string;
const template = templateStr
.replaceAll("[[SITE]]", metadata.title)
.replaceAll("[[NAME]]", metadata.name)
.replaceAll("[[TIMEZONE]]", metadata.timezone)
.replaceAll("[[YEAR]]", new Date().getFullYear().toString());
const posts = await readdir("./posts");
const defaultFrontmatter = {
thumb: "",
title: "Untitled",
desc: "",
date: "0000-00-00", // YYYY-MM-DD
@ -49,7 +50,6 @@ posts.forEach(async (post) => {
.replaceAll("[[DATE]]", frontmatter.date.toDateString())
.replaceAll("[[REVISIONS]]", `https://git.satr14.my.id/satr14/ssg.md/commits/branch/main/posts/${post}`)
.replaceAll("[[DESC]]", frontmatter.desc)
.replaceAll("[[THUMB]]", frontmatter.thumb)
.replace("[[CONTENT]]", html);
await Bun.write(`./dist/posts/${post.replace(".md", ".html")}`, render);