docusaurus-search-local
docusaurus-search-local copied to clipboard
ignoreFiles configuration details
I'm trying to use the ignoreFiles
option but it doesn't seem to be working. I've tried different strings & regex with no luck. I tried the default setting (/meta$/
) and it still index files with "meta" file name anyway. Is there something that I missed here? Any help will be much appreciated
There are some errors in the document, the default setting is not /meta$/
but []
. Even though the option is named as ignoreFiles
, however, it means ignore routes
, you should put routes in it. And, put a string if you want an exact match (without your website base url), or put a regex if you want a partial match.
The doc in readme has been updated. If it didn't help, can you share a reproduction, or share your config?
hello How should I enter to set files in the ‘docs/wip’ path not to be searched?
ignoreFiles: [/docs\/wip\/.*/],
Just beware that the filter is for routes, NOT file paths.
For example, if you serve the contents from docs/reference/api
under the route reference/api
, you must use ignoreFiles: [/reference\/api\/.*/]
. Additional implication is that such configuration doesn't exclude docs/reference/api/index.md
. If you want to exclude it as well, ignoreFiles: [/reference\/api(\/.*)?/]
should work (haven't tried, though).
Feel free to correct me, this is just my experience.
I can't get any of these suggestions to work. 😭 I have made a file '/docs/fenris.md' which includes the word 'fenris'. The file is served at http://localhost:3000/docs/fenris/ when I build locally.
I have tried every combination and it is never ignored.
["/docs/fenris/.*/"]
["/docs\/fenris/"]
["/docs/fenris"]
["\/docs\/fenris"]
["\/docs\/fenris\/.*\/"]
["/docs\/fenris\/.*/"]
["/docs\/fenris(\/.*)?/"]
["\/docs\/fenris(\/.*)?\/"]
["\/docs\/fenris\/.*/"]
["fenris"]
["fenris/"]
["fenris\/"]
["fenris\/.*"]
Can anyone make this work?
Here is our config:
export const searchLocalConfig = [
"@easyops-cn/docusaurus-search-local",
{
hashed: false,
indexDocs: true,
indexPages: true,
indexBlog: false,
removeDefaultStemmer: true,
docsRouteBasePath: "/docs",
docsDir: "docs",
highlightSearchTermsOnTargetPage: true,
explicitSearchResultPath: true,
language: ["en"],
ignoreFiles: ["\/docs\/fenris\/.*\/"],
} satisfies PluginOptions,
]
my config has no apostrophs have you tried RegExp instead of string ignoreFiles: [/docs/fenris/.*/],
Thanks for your tip. I tried removing the quotation marks, but it gave me a ParseError:
Error: Docusaurus could not load module at path "C:\gitworkspace\developer-docs\docusaurus.config.ts"
Cause: ParseError: C:\: Invalid regular expression flag.
But then I got the idea to try this, which worked!
var myRegexfilter = new RegExp(".*fenris.*", "i");
export const searchLocalConfig = [
"@easyops-cn/docusaurus-search-local",
{
hashed: false,
indexDocs: true,
indexPages: true,
indexBlog: false,
removeDefaultStemmer: true,
docsRouteBasePath: "/docs",
docsDir: "docs",
highlightSearchTermsOnTargetPage: true,
explicitSearchResultPath: true,
language: ["en"],
ignoreFiles: [myRegexfilter],
} satisfies PluginOptions,
]
😀