mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-12 14:28:09 +02:00
refactor: enforce named capture groups; clean up regexes (#6524)
* refactor: enforce named capture groups; clean up regexes * fixes * fix
This commit is contained in:
parent
c56e6194b4
commit
1cefb643dd
32 changed files with 80 additions and 77 deletions
|
@ -63,7 +63,7 @@ export function getBlogTags(blogPosts: BlogPost[]): BlogTags {
|
|||
}
|
||||
|
||||
const DATE_FILENAME_REGEX =
|
||||
/^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(\/index)?.mdx?$/;
|
||||
/^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(?:\/index)?.mdx?$/;
|
||||
|
||||
type ParsedBlogFileName = {
|
||||
date: Date | undefined;
|
||||
|
@ -83,7 +83,7 @@ export function parseBlogFileName(
|
|||
const slug = `/${slugDate}/${folder}${text}`;
|
||||
return {date, text, slug};
|
||||
}
|
||||
const text = blogSourceRelative.replace(/(\/index)?\.mdx?$/, '');
|
||||
const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
|
||||
const slug = `/${text}`;
|
||||
return {date: undefined, text, slug};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue