`preIndexRender` -> `node_preIndexRender` for stripping by serializer

pull/2770/head
Damien Guard 3 years ago
parent 35e48853af
commit af13956e2a
No known key found for this signature in database
GPG Key ID: DAD197427166C0C6

@ -120,7 +120,7 @@ export default defineConfig({
- Type: `(html: string, env: MarkdownEnv, render: (markdown: string) => string) => string` - Type: `(html: string, env: MarkdownEnv, render: (markdown: string) => string) => string`
You can pass a `preIndexRender` function to `themeConfig.search.options` that can modify or return entirely different HTML content before it is indexed. While processing in Node (not available client-side) you can pass a `node_preIndexRender` function to `themeConfig.search.options` that can modify or return entirely different HTML content before it is indexed.
The function receives the following parameters: The function receives the following parameters:
@ -137,7 +137,7 @@ export default defineConfig({
themeConfig: { themeConfig: {
search: { search: {
options: { options: {
preIndexRender: (html, env, render) => node_preIndexRender: (html, env, render) =>
env.frontmatter?.title env.frontmatter?.title
? render('# ' + env.frontmatter?.title) + html ? render('# ' + env.frontmatter?.title) + html
: html : html

@ -64,8 +64,8 @@ export async function localSearchPlugin(
if (searchConfig.options?.exclude?.(relativePath)) { if (searchConfig.options?.exclude?.(relativePath)) {
return '' return ''
} }
if (searchConfig?.options?.preIndexRender) { if (searchConfig?.options?.node_preIndexRender) {
return searchConfig.options.preIndexRender(html, env, (markdown) => return searchConfig.options.node_preIndexRender(html, env, (markdown) =>
md.render(markdown, env) md.render(markdown, env)
) )
} }

@ -388,9 +388,9 @@ export namespace DefaultTheme {
exclude?: (relativePath: string) => boolean exclude?: (relativePath: string) => boolean
/** /**
* Allow transformation of content before indexing * Allow transformation of content before indexing (from Node only)
*/ */
preIndexRender?: ( node_preIndexRender?: (
html: string, html: string,
env: MarkdownEnv, env: MarkdownEnv,
render: (string) => string render: (string) => string

Loading…
Cancel
Save