mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat(sitemap): add ignorePatterns option (#6979)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
bd70cfc1d7
commit
103ea04661
9 changed files with 78 additions and 14 deletions
|
@ -31,11 +31,16 @@ type Matcher = (str: string) => boolean;
|
|||
* A very thin wrapper around `Micromatch.makeRe`.
|
||||
*
|
||||
* @see {@link createAbsoluteFilePathMatcher}
|
||||
* @param patterns A list of glob patterns.
|
||||
* @param patterns A list of glob patterns. If the list is empty, it defaults to
|
||||
* matching none.
|
||||
* @returns A matcher handle that tells if a file path is matched by any of the
|
||||
* patterns.
|
||||
*/
|
||||
export function createMatcher(patterns: string[]): Matcher {
|
||||
if (patterns.length === 0) {
|
||||
// `/(?:)/.test("foo")` is `true`
|
||||
return () => false;
|
||||
}
|
||||
const regexp = new RegExp(
|
||||
patterns.map((pattern) => Micromatch.makeRe(pattern).source).join('|'),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue