Compare commits
2 Commits
99dd49b077
...
d78d15d8ec
| Author | SHA1 | Date |
|---|---|---|
|
|
d78d15d8ec | |
|
|
f877a58a31 |
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ export const HeadingNode: Component<{
|
||||||
if (e.button === 0) {
|
if (e.button === 0) {
|
||||||
// Left-click: use SPA navigation
|
// Left-click: use SPA navigation
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate(href());
|
navigate(`${props.basePath}#${anchor}`);
|
||||||
}
|
}
|
||||||
// Middle-click / right-click: let the browser handle the <a> natively
|
// Middle-click / right-click: let the browser handle the <a> natively
|
||||||
// 滚动到目标元素,考虑导航栏高度偏移
|
// 滚动到目标元素,考虑导航栏高度偏移
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue