From 974f60ffac3a410692bb73035c5aeefc00acebea Mon Sep 17 00:00:00 2001 From: kbot Date: Mon, 6 Jul 2026 22:07:00 -0500 Subject: [PATCH] callouts: container directive support, mono tags --- components/ui/Callout.tsx | 22 ++++++++++++---------- lib/callout-directive.js | 15 +++++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/components/ui/Callout.tsx b/components/ui/Callout.tsx index 8bfb65f..63e0a5f 100644 --- a/components/ui/Callout.tsx +++ b/components/ui/Callout.tsx @@ -8,11 +8,11 @@ interface CalloutProps { children: ReactNode; } -const iconMap: Record = { - note: 'ℹ️', - tip: '💡', - warning: '⚠️', - danger: '🚫', +const tagMap: Record = { + note: 'NOTE', + tip: 'TIP', + warning: 'WARNING', + danger: 'DANGER', }; const typeClasses: Record = { @@ -27,12 +27,14 @@ export function Callout({ type = 'note', title, children }: CalloutProps) { return (
- {title && ( -
- {iconMap[type] || iconMap.note} +
+ + {tagMap[type] || tagMap.note} + + {title && ( {title} -
- )} + )} +
{children}
); diff --git a/lib/callout-directive.js b/lib/callout-directive.js index 4837943..824794c 100644 --- a/lib/callout-directive.js +++ b/lib/callout-directive.js @@ -3,8 +3,12 @@ import { visit } from 'unist-util-visit'; export default function calloutDirective() { return (tree) => { visit(tree, (node) => { - // Handle textDirective (has content) and leafDirective (no content) - if (node.type === 'textDirective' || node.type === 'leafDirective') { + // Handle textDirective, leafDirective, and containerDirective callouts + if ( + node.type === 'textDirective' || + node.type === 'leafDirective' || + node.type === 'containerDirective' + ) { const name = node.name; // Only handle known callout types @@ -12,11 +16,10 @@ export default function calloutDirective() { if (!validTypes.includes(name)) return; // Extract attributes (e.g., title="...") - const attributes = node.attributes || []; - const attrs = attributes.map((attr) => ({ + const attrs = Object.entries(node.attributes ?? {}).map(([name, value]) => ({ type: 'mdxJsxAttribute', - name: attr.name, - value: attr.value, + name, + value, })); // Add type attribute