mirror of
https://github.com/alrayyes/wiki.git
synced 2025-06-08 14:43:39 +00:00
base path refactor to better support subpath hosting
This commit is contained in:
parent
3201f83b70
commit
c874e7e937
29 changed files with 257 additions and 389 deletions
quartz/components/scripts
|
@ -1,11 +1,11 @@
|
|||
import { Document } from "flexsearch"
|
||||
import { ContentDetails } from "../../plugins/emitters/contentIndex"
|
||||
import { registerEscapeHandler, removeAllChildren } from "./util"
|
||||
import { CanonicalSlug, getClientSlug, resolveRelative } from "../../util/path"
|
||||
import { FullSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path"
|
||||
|
||||
interface Item {
|
||||
id: number
|
||||
slug: CanonicalSlug
|
||||
slug: FullSlug
|
||||
title: string
|
||||
content: string
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ document.addEventListener("nav", async (e: unknown) => {
|
|||
const searchIcon = document.getElementById("search-icon")
|
||||
const searchBar = document.getElementById("search-bar") as HTMLInputElement | null
|
||||
const results = document.getElementById("results-container")
|
||||
const idDataMap = Object.keys(data) as CanonicalSlug[]
|
||||
const idDataMap = Object.keys(data) as FullSlug[]
|
||||
|
||||
function hideSearch() {
|
||||
container?.classList.remove("active")
|
||||
|
@ -126,7 +126,7 @@ document.addEventListener("nav", async (e: unknown) => {
|
|||
button.innerHTML = `<h3>${title}</h3><p>${content}</p>`
|
||||
button.addEventListener("click", () => {
|
||||
const targ = resolveRelative(currentSlug, slug)
|
||||
window.spaNavigate(new URL(targ, getClientSlug(window)))
|
||||
window.spaNavigate(new URL(targ, window.location.toString()))
|
||||
})
|
||||
return button
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ document.addEventListener("nav", async (e: unknown) => {
|
|||
for (const [slug, fileData] of Object.entries<ContentDetails>(data)) {
|
||||
await index.addAsync(id, {
|
||||
id,
|
||||
slug: slug as CanonicalSlug,
|
||||
slug: slug as FullSlug,
|
||||
title: fileData.title,
|
||||
content: fileData.content,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue