From 057eb335d6c5fdfee850c007e3cab31e6b37ac52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Mon, 22 Jun 2026 16:07:10 +0200 Subject: [PATCH] feat: render @example code blocks before other tags --- src/components/Comment.tsx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/Comment.tsx b/src/components/Comment.tsx index 80148de..ee9957c 100644 --- a/src/components/Comment.tsx +++ b/src/components/Comment.tsx @@ -12,6 +12,7 @@ const TAG_DEFAULT_MESSAGES: Record = { const TAG_PREFIX: Record = { '@deprecated': 'Deprecated - ', '@see': 'See more at ', + '@throws': 'Throws - ' }; const ALWAYS_HIDDEN = new Set(['@reference', '@since']); @@ -118,22 +119,27 @@ export interface CommentTagsProps { hideTags?: string[]; } +function renderTag(tag: JSONOutput.CommentTag) { + const content = resolveTagContent(tag); + + if (!content) return null; + + return ( +
+ +
+ ); +} + export function CommentTags({ comment, hideTags = EMPTY_TAGS }: CommentTagsProps) { const blockTags = filterBlockTags(comment?.blockTags ?? [], hideTags); + const examples = blockTags.filter((tag) => tag.tag === '@example'); + const rest = blockTags.filter((tag) => tag.tag !== '@example'); return ( <> - {blockTags.map((tag) => { - const content = resolveTagContent(tag); - - if (!content) return null; - - return ( -
- -
- ); - })} + {examples.map(renderTag)} + {rest.map(renderTag)} ); }