mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 10:54:06 -06:00
Merge 8de40437a1 into e77a051144
This commit is contained in:
commit
d7e7d7665c
@ -9,6 +9,8 @@ interface Item {
|
||||
title: string
|
||||
content: string
|
||||
tags: string[]
|
||||
aliases: string[]
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
// Can be expanded with things like "term" in the future
|
||||
@ -35,6 +37,10 @@ let index = new FlexSearch.Document<Item>({
|
||||
field: "tags",
|
||||
tokenize: "forward",
|
||||
},
|
||||
{
|
||||
field: "aliases",
|
||||
tokenize: "forward",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
@ -271,6 +277,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
||||
title: searchType === "tags" ? data[slug].title : highlight(term, data[slug].title ?? ""),
|
||||
content: highlight(term, data[slug].content ?? "", true),
|
||||
tags: highlightTags(term.substring(1), data[slug].tags),
|
||||
aliases: data[slug].aliases ?? [],
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,7 +416,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
||||
query: query,
|
||||
// return at least 10000 documents, so it is enough to filter them by tag (implemented in flexsearch)
|
||||
limit: Math.max(numSearchResults, 10000),
|
||||
index: ["title", "content"],
|
||||
index: ["title", "content", "aliases"],
|
||||
tag: tag,
|
||||
})
|
||||
for (let searchResult of searchResults) {
|
||||
@ -430,7 +437,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
||||
searchResults = await index.searchAsync({
|
||||
query: currentSearchTerm,
|
||||
limit: numSearchResults,
|
||||
index: ["title", "content"],
|
||||
index: ["title", "content", "aliases"],
|
||||
})
|
||||
}
|
||||
|
||||
@ -442,6 +449,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
||||
// order titles ahead of content
|
||||
const allIds: Set<number> = new Set([
|
||||
...getByField("title"),
|
||||
...getByField("aliases"),
|
||||
...getByField("content"),
|
||||
...getByField("tags"),
|
||||
])
|
||||
@ -478,6 +486,7 @@ async function fillDocument(data: ContentIndex) {
|
||||
title: fileData.title,
|
||||
content: fileData.content,
|
||||
tags: fileData.tags,
|
||||
aliases: fileData.aliases,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ export type ContentDetails = {
|
||||
links: SimpleSlug[]
|
||||
tags: string[]
|
||||
content: string
|
||||
aliases: string[]
|
||||
richContent?: string
|
||||
date?: Date
|
||||
description?: string
|
||||
@ -110,6 +111,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
links: file.data.links ?? [],
|
||||
tags: file.data.frontmatter?.tags ?? [],
|
||||
content: file.data.text ?? "",
|
||||
aliases: file.data.frontmatter?.aliases ?? [],
|
||||
richContent: opts?.rssFullHtml
|
||||
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
|
||||
: undefined,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user