From a797c4c8a27192e321a5b62699d9068f45fe5b49 Mon Sep 17 00:00:00 2001 From: satr14 Date: Fri, 12 Jun 2026 19:06:34 +0700 Subject: [PATCH] disable tracking on drafts --- index.ts | 4 ++++ templates/post.html | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index c12e449..0e79e57 100644 --- a/index.ts +++ b/index.ts @@ -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 = ``; 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 + ? "" + : TRACKER_HEADER) .replaceAll("[[TITLE]]", `${metadata.title} - ${frontmatter.title}`) .replaceAll("[[POST_TITLE]]", frontmatter.title) .replaceAll("[[DATE]]", frontmatter.date.toDateString()) diff --git a/templates/post.html b/templates/post.html index 2f3c276..5df0fb4 100644 --- a/templates/post.html +++ b/templates/post.html @@ -5,8 +5,8 @@ [[TITLE]] - - + [[HEAD_EXTRA]] +