From 8c9506c1065079ec1156b50c1c2831e8c0f33208 Mon Sep 17 00:00:00 2001 From: hypercross Date: Tue, 14 Jul 2026 15:56:38 +0800 Subject: [PATCH] fix: strip .md extension from resolved article paths Ensures that navigation to markdown files strips the extension, allowing the SPA fallback to handle refreshes instead of requesting the raw file. --- src/components/Article.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Article.tsx b/src/components/Article.tsx index ca4cb1e..0e548b2 100644 --- a/src/components/Article.tsx +++ b/src/components/Article.tsx @@ -109,9 +109,14 @@ export const Article: Component = (props) => { e.preventDefault(); // Resolve relative hrefs against the current page path so that - // e.g. "blah.md" on /content/page.md becomes /content/blah.md - const resolved = new URL(href, window.location.origin + window.location.pathname).pathname; - navigate(resolved); + // e.g. "blah.md" on /content/page.md becomes /content/blah + const resolved = new URL(href, window.location.origin + window.location.pathname); + let pathname = resolved.pathname; + // Strip .md extension so refreshes hit the SPA fallback, not the raw file + if (pathname.endsWith(".md")) { + pathname = pathname.slice(0, -3); + } + navigate(pathname + resolved.hash); }; dom.addEventListener("click", onClick);