Skip to content

Commit

Permalink
Add config validation and make all options optional
Browse files Browse the repository at this point in the history
  • Loading branch information
iAdramelk committed Apr 21, 2024
1 parent aaa99aa commit 6d7f80b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 1 addition & 4 deletions packages/docusaurus-types/src/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ export type MarkdownConfig = {
remarkRehypeOptions: RemarkRehypeOptions;

anchors?: {
/**
* Ability to preserve the case of the heading anchor links.
*/
maintainCase: boolean;
maintainCase?: boolean;
};
};

Expand Down
8 changes: 8 additions & 0 deletions packages/docusaurus/src/server/configValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const DEFAULT_MARKDOWN_CONFIG: MarkdownConfig = {
admonitions: true,
headingIds: true,
},
anchors: {
maintainCase: false,
},
remarkRehypeOptions: undefined,
};

Expand Down Expand Up @@ -320,6 +323,11 @@ export const ConfigSchema = Joi.object<DocusaurusConfig>({
// Not sure if it's a good idea, validation is likely to become stale
// See https://github.com/remarkjs/remark-rehype#options
Joi.object().unknown(),
anchors: Joi.object({
maintainCase: Joi.boolean().default(
DEFAULT_CONFIG.markdown.anchors?.maintainCase,
),
}),
}).default(DEFAULT_CONFIG.markdown),
}).messages({
'docusaurus.configValidationWarning':
Expand Down
2 changes: 1 addition & 1 deletion website/docs/api/docusaurus.config.js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ type MarkdownConfig = {
mdx1Compat: MDX1CompatOptions;
remarkRehypeOptions: object; // see https://github.com/remarkjs/remark-rehype#options
anchors?: {
maintainCase: boolean;
maintainCase?: boolean;
};
};
```
Expand Down

0 comments on commit 6d7f80b

Please sign in to comment.