docusaurus-search-local icon indicating copy to clipboard operation
docusaurus-search-local copied to clipboard

ignoreFiles configuration details

Open nugroho-mr opened this issue 2 years ago • 8 comments

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

nugroho-mr avatar Aug 08 '22 06:08 nugroho-mr

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.

weareoutman avatar Aug 08 '22 07:08 weareoutman

The doc in readme has been updated. If it didn't help, can you share a reproduction, or share your config?

weareoutman avatar Aug 08 '22 08:08 weareoutman

hello How should I enter to set files in the ‘docs/wip’ path not to be searched?

ImKijung avatar Feb 08 '23 08:02 ImKijung

ignoreFiles: [/docs\/wip\/.*/],

skosysparency avatar Mar 08 '23 13:03 skosysparency

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.

roberthusak avatar Jan 30 '24 09:01 roberthusak

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,
]

rebekaburnett avatar Feb 14 '24 14:02 rebekaburnett

my config has no apostrophs have you tried RegExp instead of string ignoreFiles: [/docs/fenris/.*/],

skosysparency avatar Feb 14 '24 15:02 skosysparency

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,
]

😀

rebekaburnett avatar Feb 15 '24 07:02 rebekaburnett