feat(core): add new site config option siteConfig.markdown.anchors.maintainCase (#10064)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Ivanov 2024-04-25 23:35:38 +09:00 committed by GitHub
parent 9418786b26
commit daba917e7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 122 additions and 13 deletions

View file

@ -47,11 +47,6 @@ type SimpleProcessor = {
}) => Promise<SimpleProcessorResult>;
};
async function getDefaultRemarkPlugins(): Promise<MDXPlugin[]> {
const {default: emoji} = await import('remark-emoji');
return [headings, emoji, toc];
}
export type MDXPlugin = Pluggable;
export type MDXOptions = {
@ -86,8 +81,18 @@ async function createProcessorFactory() {
const {default: comment} = await import('@slorber/remark-comment');
const {default: directive} = await import('remark-directive');
const {VFile} = await import('vfile');
const {default: emoji} = await import('remark-emoji');
const defaultRemarkPlugins = await getDefaultRemarkPlugins();
function getDefaultRemarkPlugins({options}: {options: Options}): MDXPlugin[] {
return [
[
headings,
{anchorsMaintainCase: options.markdownConfig.anchors.maintainCase},
],
emoji,
toc,
];
}
// /!\ this method is synchronous on purpose
// Using async code here can create cache entry race conditions!
@ -104,7 +109,7 @@ async function createProcessorFactory() {
directive,
[contentTitle, {removeContentTitle: options.removeContentTitle}],
...getAdmonitionsPlugins(options.admonitions ?? false),
...defaultRemarkPlugins,
...getDefaultRemarkPlugins({options}),
details,
head,
...(options.markdownConfig.mermaid ? [mermaid] : []),