diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index d03ff77a..3afb96dc 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -16,6 +16,25 @@ import { mainConfig, defaultThemeConfig } from './configs/locales_config.js' const isProd = process.env.NODE_ENV === 'production' +const htmlEntityMap: Record = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'", + ' ': ' ', +} + +function normalizeSearchText(text: string): string { + return text + .replace(/)<[^<]*)*<\/script>/gi, ' ') + .replace(/)<[^<]*)*<\/style>/gi, ' ') + .replace(/<[^>]+>/g, ' ') + .replace(/&(amp|lt|gt|quot|#39|nbsp);/g, (match) => htmlEntityMap[match] ?? ' ') + .replace(/\s+/g, ' ') + .trim() +} + function vueTemplateTolerantPlugin(): Plugin { let compilerSfc: typeof import('@vue/compiler-sfc') | undefined return { @@ -154,6 +173,10 @@ export default defineUserConfig({ searchPlugin({ maxSuggestions: 15, hotKeys: ['s', '/'], + getExtraFields: (page) => { + const content = normalizeSearchText(page.contentRendered) + return content ? [content] : [] + }, locales: { '/': { placeholder: 'Search', diff --git a/docs/guide/chat-bots.md b/docs/guide/chat-bots.md index 1baceafe..a8705b82 100644 --- a/docs/guide/chat-bots.md +++ b/docs/guide/chat-bots.md @@ -3432,7 +3432,7 @@ redirectFrom: - - **Available values:** [Item Type List](https://raw.githubusercontent.com/MCCTeam/Minecraft-Console-Client/master/MinecraftClient/Inventory/ItemType.cs) + - **Available values:** [Item Type List](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/MinecraftClient/Inventory/ItemType.cs) - **Type:** `array of strings with item names`