local and global graph

This commit is contained in:
Jacky Zhao 2023-06-18 10:47:07 -07:00
parent 8bfee04c8c
commit c4cf0dcb02
23 changed files with 1288 additions and 110 deletions
quartz/components/scripts

View file

@ -29,8 +29,8 @@ const getOpts = ({ target }: Event): { url: URL, scroll?: boolean } | undefined
return { url: new URL(href), scroll: 'routerNoscroll' in a.dataset ? false : undefined }
}
function notifyNav(slug: string) {
const event = new CustomEvent("nav", { detail: { slug } })
function notifyNav(url: string) {
const event: CustomEventMap["nav"] = new CustomEvent("nav", { detail: { url } })
document.dispatchEvent(event)
}
@ -73,6 +73,8 @@ async function navigate(url: URL, isBack: boolean = false) {
delete announcer.dataset.persist
}
window.spaNavigate = navigate
function createRouter() {
if (typeof window !== "undefined") {
window.addEventListener("click", async (event) => {