feat: add GitHub-style admonition (GFM Alerts) support#467
feat: add GitHub-style admonition (GFM Alerts) support#467ayhansipahi wants to merge 10 commits intovercel:mainfrom
Conversation
Add a remark plugin that transforms GitHub-flavored blockquote admonitions (NOTE, TIP, IMPORTANT, WARNING, CAUTION) into styled admonition components. Includes remark plugin, minimal React component, sanitization config, component registration, and comprehensive tests.
…ntegration Add 5 SVG icon components (Note, Tip, Important, Warning, Caution) and register them in IconMap. Add translation strings for admonition titles. Update the admonition component to use useIcons() and useTranslations() hooks instead of hardcoded title text. Add tests for icon rendering, custom translations, and component override support.
Title text and icon rendering tests now verify all 5 admonition types instead of only testing NOTE.
Extract detectAdmonitionType and stripMarker helper functions to bring cognitive complexity below the linter threshold. Also apply formatter fixes to test file.
Add all 5 admonition types (NOTE, TIP, IMPORTANT, WARNING, CAUTION) to the playground's default markdown showcase.
|
@ayhansipahi is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
9de5cc9 to
60031a6
Compare
|
Awesome thanks @ayhansipahi - im surprised this isn't included in GFM! I was reading remarkjs/remark-gfm#62 and found there's some existing rehype plugins we could use instead of rolling our own e.g. https://github.com/chrisweb/rehype-github-alerts |
|
Thanks for the catch, @haydenbleasel. I didn't notice this plugin. I'll update the PR. |
Actually, after looking into
Agreed it's surprising this isn't in GFM though — that discussion thread has been open for a while! |
|
ok that makes sense. in that case i feel like we should potentially create a new package called remark-gfm-admonition which we can publish separately so others can use it, import that into Streamdown alongside the other remark plugins and leave Remend to handle it's core focus (markdown healing). |
|
Good call! The monorepo already has a clear pattern with |
0de21ff to
1c70a02
Compare
Create a new `remark-gfm-admonition` package that parses GitHub-flavored admonition blockquotes ([!NOTE], [!TIP], etc.) and produces GitHub-compatible HTML output. Streamdown now consumes this package via a thin post-processor that maps the output to its React component system.
1c70a02 to
b54e355
Compare
| "unified": "^11.0.5", | ||
| "vitest": "^4.0.15" | ||
| }, | ||
| "author": "Hayden Bleasel <hayden.bleasel@vercel.com>", |
There was a problem hiding this comment.
It's entirely up to you whether or not to give me credit. I don't mind either way.
Summary
> [!NOTE],> [!TIP],> [!IMPORTANT],> [!WARNING],> [!CAUTION])[!TYPE]markers into styled callout boxes with type-specific icons and colorscomponents,icons, andtranslationspropsNew files
packages/streamdown/lib/remark/admonition.ts— Remark plugin (AST-level transformation)packages/streamdown/lib/admonition.tsx— Memoized React component with 5 color themespackages/streamdown/__tests__/admonition.test.tsx— 13 tests covering plugin + component featuresapps/website/content/docs/admonitions.mdx— Documentation pageModified files
packages/streamdown/lib/icons.tsx— 5 new SVG icon componentspackages/streamdown/lib/icon-context.tsx— Extended IconMap interfacepackages/streamdown/lib/translations-context.tsx— 5 new i18n keyspackages/streamdown/lib/components.tsx— Register admonition componentpackages/streamdown/index.tsx— Add to default remark plugins + sanitize schema + exportapps/website/content/docs/components.mdx— Add admonition to available components listapps/website/content/docs/internationalization.mdx— Add admonition translation keysapps/website/content/docs/gfm.mdx— Cross-link to admonitions pageapps/website/app/[lang]/playground/components/playground-editor.tsx— Add admonition examplesTest plan
ultracite check)pnpm check-types)