[Feature]: Custom admonitions
What problem does this feature solve?
Doc sites using docusaurus or other frameworks may have custom admonitions throughout 100s of files. Allowing them to migrate their admonitions without having to update copy would bolster migration.
https://docusaurus.io/docs/markdown-features/admonitions#customizing-admonitions
What does the proposed API look like?
Example config
themeConfig: {
admonitions: {
extensions: ['branded-warning'],
uiComponents: [path.join(__dirname, 'components', 'CustomAdmonition.tsx')]
},
},
const CustomAdmonition = ({ level, children }: { level: string }) => {
if(level === "branded-warning") {
return <BrandedWarningAdmonition>{children}</BrandedWarningAdmonition>
}
}
In Rspress, we've been calling admonition as container for a while, so I prefer markdown.container
ref: https://github.com/web-infra-dev/rspress/blob/73e84b61778eb5f0e7d80580f8bc095c696c18aa/packages/core/src/node/mdx/remarkPlugins/containerSyntax.ts#L3
Our current grammar has certain differences from Docusaurus, and I believe we may not be able to align all of Docusaurus' configurations. However, it can be determined that we need to refactor the remark plugin related to the container to expose certain configuration options.
So we have a long way to go to align all the configurations of Docusaurus, perhaps we can first extract the Container into a React component first for them.
some small tasks here:
- extract
Containeras React Component
<Container> </Container>
- discuss custom configuration items of
markdown.container
...
ref:
-
https://vitepress.dev/guide/markdown#custom-containers
-
https://fumadocs.dev/docs/headless/mdx/remark-admonition
Thanks for the details @SoonIter - if I find some time I will have a look at contributing
https://github.com/web-infra-dev/rspress/pull/2708#issuecomment-3484944346