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);