Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support directive-based admonitions and alerts for mdx and md sources #644

Closed
cameronraysmith opened this issue Jul 26, 2024 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@cameronraysmith
Copy link

cameronraysmith commented Jul 26, 2024

What problem will this feature address?

Several widely-used markdown extensions such as those in

use directives or other syntax to support alerts, admonitions, etc.

examples of directive-based admonition/alert syntax that may be used in md(x) taken from the docusaurus docs

:::note

Some **content** with _Markdown_ `syntax`. Check [this `api`](#).

:::

:::tip

Some **content** with _Markdown_ `syntax`. Check [this `api`](#).

:::

:::info

Some **content** with _Markdown_ `syntax`. Check [this `api`](#).

:::

:::warning

Some **content** with _Markdown_ `syntax`. Check [this `api`](#).

:::

:::danger

Some **content** with _Markdown_ `syntax`. Check [this `api`](#).

:::

Describe the solution you'd like

It would be helpful to support github-flavored markdown or mdx files that contain this style of alert or directive-based admonition syntax.

Describe alternatives you've considered

fumadocs already supports this via components in mdx for example

import { Callout } from "fumadocs-ui/components/callout";

<Callout type="info">
  Information
</Callout>

<Callout type="warn">
  Warning
</Callout>

...

however, I am not sure if there is a built-in approach to translate the directive syntax like that utilized by docusaurus to Callout components using a custom MDX -> JSX transform function with a content-collection source for mdx.

It should also be possible to use remark plugins

together with appropriate styles to support this with markdown if there is not already a simpler approach I am not aware of. This could be facilitated by a complementary content-collection MD -> HTML transform function for markdown

@cameronraysmith cameronraysmith added the enhancement New feature or request label Jul 26, 2024
@cameronraysmith cameronraysmith changed the title Support directive-based admonitions and alerts Support directive-based admonitions and alerts for mdx and md sources Jul 26, 2024
@cameronraysmith
Copy link
Author

cameronraysmith commented Jul 26, 2024

@fuma-nama
Copy link
Owner

I personally avoid these syntax as it is not the standard of CommonMark and MDX, but JSX is. I think we can offer a rehype plugin for people migrating from other docs frameworks as JSX (using the component directly) is more flexible and friendly.

In MDX, intellisense works for directly imported components which makes it significantly easier to use.

@cameronraysmith
Copy link
Author

cameronraysmith commented Jul 27, 2024

I agree. For my use case it's probably better to just write a pandoc lua filter | like this one for docusaurus that specifically targets translation to fumadocs-compatible Callout components in MDX wherever the source markdown uses directive syntax. I will close this as I think that will likely be a better solution and shouldn't require any change to fumadocs. Many thanks!

@cameronraysmith cameronraysmith closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants