mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 01:47:17 +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};
|
||||
}
|
||||
|
|
|
@ -452,7 +452,7 @@ export default async function pluginContentBlog(
|
|||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /(\.mdx?)$/,
|
||||
test: /\.mdx?$/i,
|
||||
include: contentDirs
|
||||
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
||||
.map(addTrailingPathSeparator),
|
||||
|
|
|
@ -20,7 +20,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
beforeDefaultRehypePlugins: [],
|
||||
beforeDefaultRemarkPlugins: [],
|
||||
admonitions: {},
|
||||
truncateMarker: /<!--\s*(truncate)\s*-->/,
|
||||
truncateMarker: /<!--\s*truncate\s*-->/,
|
||||
rehypePlugins: [],
|
||||
remarkPlugins: [],
|
||||
showReadingTime: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue