disable tracking on drafts

This commit is contained in:
Satria 2026-06-12 19:06:34 +07:00
commit a797c4c8a2
2 changed files with 6 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import metadata from "./metadata.json";
import templateRaw from "./templates/post.html" with { type: "text" };
import homeRaw from "./templates/home.html" with { type: "text" };
const TRACKER_HEADER = `<script defer src="https://a.satr14.my.id/script.js" data-website-id="fe5155fe-e5dc-4096-a524-0c2589c859a7"></script>`;
const year = new Date().getFullYear().toString();
const applyVars = (raw: unknown) => (raw as string)
.replaceAll("[[SITE]]", metadata.title)
@ -51,6 +52,9 @@ await Promise.all(posts.map(async (post) => {
tagFilter: true,
});
const render = template
.replaceAll("[[HEAD_EXTRA]]", frontmatter.draft
? "<meta name=\"robots\" content=\"noindex\">"
: TRACKER_HEADER)
.replaceAll("[[TITLE]]", `${metadata.title} - ${frontmatter.title}`)
.replaceAll("[[POST_TITLE]]", frontmatter.title)
.replaceAll("[[DATE]]", frontmatter.date.toDateString())