From f345a25a7b6f113177e583112f1519d139001554 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 13 Mar 2025 15:46:19 +0800 Subject: [PATCH] feat: enable `search.codeBlocks` by default --- e2e/fixtures/search-code-blocks/rspress.config.ts | 3 --- packages/core/src/node/runtimeModule/siteData/index.ts | 2 +- packages/document/docs/en/api/config/config-basic.mdx | 6 +++--- packages/document/docs/zh/api/config/config-basic.mdx | 6 +++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/e2e/fixtures/search-code-blocks/rspress.config.ts b/e2e/fixtures/search-code-blocks/rspress.config.ts index 399522b20..0731c0907 100644 --- a/e2e/fixtures/search-code-blocks/rspress.config.ts +++ b/e2e/fixtures/search-code-blocks/rspress.config.ts @@ -3,7 +3,4 @@ import { defineConfig } from 'rspress/config'; export default defineConfig({ root: path.join(__dirname, 'doc'), - search: { - codeBlocks: true, - }, }); diff --git a/packages/core/src/node/runtimeModule/siteData/index.ts b/packages/core/src/node/runtimeModule/siteData/index.ts index 274b26c49..caa31a28f 100644 --- a/packages/core/src/node/runtimeModule/siteData/index.ts +++ b/packages/core/src/node/runtimeModule/siteData/index.ts @@ -51,7 +51,7 @@ export async function siteDataVMPlugin(context: FactoryContext) { searchConfig?.mode === 'remote' ? (searchConfig.domain ?? '') : ''; const searchCodeBlocks = - 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : false; + 'codeBlocks' in searchConfig ? Boolean(searchConfig.codeBlocks) : true; const pages = await extractPageData( replaceRules, diff --git a/packages/document/docs/en/api/config/config-basic.mdx b/packages/document/docs/en/api/config/config-basic.mdx index 3c52e307a..2ddcd324a 100644 --- a/packages/document/docs/en/api/config/config-basic.mdx +++ b/packages/document/docs/en/api/config/config-basic.mdx @@ -312,16 +312,16 @@ export default defineConfig({ ### codeBlocks - Type: `boolean` -- Default: `false` +- Default: `true` -If enabled, the search index will include code block content, which allows users to search code blocks. +Whether to include code block content in the search index, which allows users to search code blocks. ```ts title="rspress.config.ts" import { defineConfig } from 'rspress/config'; export default defineConfig({ search: { - codeBlocks: true, + codeBlocks: false, }, }); ``` diff --git a/packages/document/docs/zh/api/config/config-basic.mdx b/packages/document/docs/zh/api/config/config-basic.mdx index 45e01e62a..dcfb58eb5 100644 --- a/packages/document/docs/zh/api/config/config-basic.mdx +++ b/packages/document/docs/zh/api/config/config-basic.mdx @@ -311,16 +311,16 @@ export default defineConfig({ ### codeBlocks - Type: `boolean` -- Default: `false` +- Default: `true` -开启后,搜索的索引将包含代码块的内容,从而允许用户搜索代码块。 +是否在搜索的索引中包含代码块的内容,这可以让用户搜索代码块。 ```ts title="rspress.config.ts" import { defineConfig } from 'rspress/config'; export default defineConfig({ search: { - codeBlocks: true, + codeBlocks: false, }, }); ```