fix(Article): resolve relative hrefs during navigation

This commit is contained in:
hypercross 2026-07-14 14:18:26 +08:00
parent 99dd49b077
commit f877a58a31
1 changed files with 4 additions and 1 deletions

View File

@ -108,7 +108,10 @@ export const Article: Component<ArticleProps & ParentProps> = (props) => {
if (href.startsWith("#")) return; if (href.startsWith("#")) return;
e.preventDefault(); e.preventDefault();
navigate(href); // 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);
}; };
dom.addEventListener("click", onClick); dom.addEventListener("click", onClick);