mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-03 19:19:42 -04:00
Merge of Insiders features tied to 'Aji Panca' funding goal
This commit is contained in:
@@ -55,6 +55,7 @@ export interface SearchIndexDocument {
|
||||
location: string /* Document location */
|
||||
title: string /* Document title */
|
||||
text: string /* Document text */
|
||||
tags?: string[] /* Document tags */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -202,6 +203,7 @@ export class Search {
|
||||
/* Set up fields */
|
||||
this.field("title", { boost: 1e3 })
|
||||
this.field("text")
|
||||
this.field("tags", { boost: 1e6 })
|
||||
|
||||
/* Index documents */
|
||||
for (const doc of docs)
|
||||
@@ -243,7 +245,7 @@ export class Search {
|
||||
.reduce<SearchResultItem>((item, { ref, score, matchData }) => {
|
||||
const document = this.documents.get(ref)
|
||||
if (typeof document !== "undefined") {
|
||||
const { location, title, text, parent } = document
|
||||
const { location, title, text, tags, parent } = document
|
||||
|
||||
/* Compute and analyze search query terms */
|
||||
const terms = getSearchQueryTerms(
|
||||
@@ -257,6 +259,7 @@ export class Search {
|
||||
location,
|
||||
title: highlight(title),
|
||||
text: highlight(text),
|
||||
...tags && { tags: tags.map(highlight) },
|
||||
score: score * (1 + boost),
|
||||
terms
|
||||
})
|
||||
|
||||
@@ -61,9 +61,10 @@ export function setupSearchDocumentMap(
|
||||
for (const doc of docs) {
|
||||
const [path, hash] = doc.location.split("#")
|
||||
|
||||
/* Extract location and title */
|
||||
/* Extract location, title and tags */
|
||||
const location = doc.location
|
||||
const title = doc.title
|
||||
const tags = doc.tags
|
||||
|
||||
/* Escape and cleanup text */
|
||||
const text = escapeHTML(doc.text)
|
||||
@@ -97,7 +98,8 @@ export function setupSearchDocumentMap(
|
||||
documents.set(location, {
|
||||
location,
|
||||
title,
|
||||
text
|
||||
text,
|
||||
...tags && { tags }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user