Compare commits
No commits in common. "d78d15d8ecc3c848d127f154fe712c8ea2c837df" and "99dd49b077cc597965717084e4c2791563de8215" have entirely different histories.
d78d15d8ec
...
99dd49b077
|
|
@ -108,10 +108,7 @@ export const Article: Component<ArticleProps & ParentProps> = (props) => {
|
||||||
if (href.startsWith("#")) return;
|
if (href.startsWith("#")) return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Resolve relative hrefs against the current page path so that
|
navigate(href);
|
||||||
// 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(`${props.basePath}#${anchor}`);
|
navigate(href());
|
||||||
}
|
}
|
||||||
// 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