mirror of
https://github.com/ZetaKebab/quartz.git
synced 2025-06-22 00:34:37 +00:00
fix: cleanup a href link construction, global shared trie, breadcrumbs use trie
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import { QuartzConfig } from "../cfg"
|
||||
import { QuartzPluginData } from "../plugins/vfile"
|
||||
import { FileTrieNode } from "./fileTrie"
|
||||
import { FilePath, FullSlug } from "./path"
|
||||
|
||||
export interface Argv {
|
||||
@ -13,13 +15,36 @@ export interface Argv {
|
||||
concurrency?: number
|
||||
}
|
||||
|
||||
export type BuildTimeTrieData = QuartzPluginData & {
|
||||
slug: string
|
||||
title: string
|
||||
filePath: string
|
||||
}
|
||||
|
||||
export interface BuildCtx {
|
||||
buildId: string
|
||||
argv: Argv
|
||||
cfg: QuartzConfig
|
||||
allSlugs: FullSlug[]
|
||||
allFiles: FilePath[]
|
||||
trie?: FileTrieNode<BuildTimeTrieData>
|
||||
incremental: boolean
|
||||
}
|
||||
|
||||
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg">
|
||||
export function trieFromAllFiles(allFiles: QuartzPluginData[]): FileTrieNode<BuildTimeTrieData> {
|
||||
const trie = new FileTrieNode<BuildTimeTrieData>([])
|
||||
allFiles.forEach((file) => {
|
||||
if (file.frontmatter) {
|
||||
trie.add({
|
||||
...file,
|
||||
slug: file.slug!,
|
||||
title: file.frontmatter.title,
|
||||
filePath: file.filePath!,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return trie
|
||||
}
|
||||
|
||||
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg" | "trie">
|
||||
|
Reference in New Issue
Block a user