mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 17:22:35 +02:00
feat(v2): docs, make numberPrefixParser configurable, better defaults, minor breaking-changes (#4655)
* make number prefix parsing logic configurable * Make numberPrefixParser configurable + rename frontmatter + avoid parsing date/version patterns by default * add more tests * more test cases
This commit is contained in:
parent
d0d29f43cc
commit
c04e613ffe
14 changed files with 325 additions and 82 deletions
|
@ -16,6 +16,10 @@ import {OptionValidationContext, ValidationResult} from '@docusaurus/types';
|
|||
import chalk from 'chalk';
|
||||
import admonitions from 'remark-admonitions';
|
||||
import {DefaultSidebarItemsGenerator} from './sidebarItemsGenerator';
|
||||
import {
|
||||
DefaultNumberPrefixParser,
|
||||
DisabledNumberPrefixParser,
|
||||
} from './numberPrefix';
|
||||
|
||||
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id'> = {
|
||||
path: 'docs', // Path to data on filesystem, relative to site dir.
|
||||
|
@ -24,6 +28,7 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id'> = {
|
|||
include: ['**/*.{md,mdx}'], // Extensions to include.
|
||||
sidebarPath: 'sidebars.json', // Path to the sidebars configuration file
|
||||
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
||||
numberPrefixParser: DefaultNumberPrefixParser,
|
||||
docLayoutComponent: '@theme/DocPage',
|
||||
docItemComponent: '@theme/DocItem',
|
||||
remarkPlugins: [],
|
||||
|
@ -66,6 +71,17 @@ export const OptionsSchema = Joi.object({
|
|||
sidebarItemsGenerator: Joi.function().default(
|
||||
() => DEFAULT_OPTIONS.sidebarItemsGenerator,
|
||||
),
|
||||
numberPrefixParser: Joi.alternatives()
|
||||
.try(
|
||||
Joi.function(),
|
||||
// Convert boolean values to functions
|
||||
Joi.alternatives().conditional(Joi.boolean(), {
|
||||
then: Joi.custom((val) =>
|
||||
val ? DefaultNumberPrefixParser : DisabledNumberPrefixParser,
|
||||
),
|
||||
}),
|
||||
)
|
||||
.default(() => DEFAULT_OPTIONS.numberPrefixParser),
|
||||
docLayoutComponent: Joi.string().default(DEFAULT_OPTIONS.docLayoutComponent),
|
||||
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
||||
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue