feat: mark active or ancestor links (#1840)

This commit is contained in:
Marvin Hagemeister
2023-10-02 18:22:44 +02:00
committed by GitHub
parent d638c526f5
commit 4295dbe85d
11 changed files with 304 additions and 138 deletions
+7
View File
@@ -19,6 +19,7 @@ import {
PARTIAL_SEARCH_PARAM,
PartialMode,
} from "../../constants.ts";
import { setActiveUrl } from "../active_url.ts";
function createRootFragment(
parent: Element,
@@ -704,6 +705,12 @@ export async function applyPartials(res: Response): Promise<void> {
const originalHook = options.vnode;
options.vnode = (vnode) => {
assetHashingHook(vnode);
// Mark active or ancestor links
if (vnode.type === "a") {
setActiveUrl(vnode, location.pathname);
}
if (originalHook) originalHook(vnode);
};