From e57be64043fcde3d619efc24cbdbf24f37eb3c18 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Fri, 27 Mar 2026 15:09:16 +0100 Subject: [PATCH] added citations --- frontend/src/pages/posts/[slug].astro | 22 +++++++++++++--- frontend/src/styles/global.css | 38 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/posts/[slug].astro b/frontend/src/pages/posts/[slug].astro index 3e99f2f..da4c595 100644 --- a/frontend/src/pages/posts/[slug].astro +++ b/frontend/src/pages/posts/[slug].astro @@ -14,12 +14,30 @@ let post: PostDetail | null = null; let html = ''; let error = ''; +// Custom citation pre-processor +function processCitations(text: string) { + // Using RegExp constructor to completely bypass Astro/esbuild literal parsing bugs + const citeRegex = new RegExp('\\', 'g'); + + return text.replace(citeRegex, (match, citations) => { + const links = citations.split(',').map((c: string) => { + const id = c.trim(); + return `${id}`; + }).join(', '); + + return `[${links}]`; + }); +} + try { const response = await fetch(`${API_URL}/api/posts/${slug}`); if (response.ok) { post = await response.json(); if (post) { - html = await marked.parse(post.content); + // 1. Process citations first + const processedContent = processCitations(post.content); + // 2. Then parse the rest of the markdown + html = await marked.parse(processedContent); } } else { error = 'Post not found'; @@ -76,12 +94,10 @@ function formatSlug(slug: string) { )} - -