Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const TAG_DEFAULT_MESSAGES: Record<string, string> = {
const TAG_PREFIX: Record<string, string> = {
'@deprecated': 'Deprecated - ',
'@see': 'See more at ',
'@throws': 'Throws - '
};

const ALWAYS_HIDDEN = new Set(['@reference', '@since']);
Expand Down Expand Up @@ -118,22 +119,27 @@ export interface CommentTagsProps {
hideTags?: string[];
}

function renderTag(tag: JSONOutput.CommentTag) {
const content = resolveTagContent(tag);

if (!content) return null;

return (
<div key={`${tag.tag}-${content}`} className="tsd-comment-since">
<Markdown content={content} />
</div>
);
}

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 (
<div key={`${tag.tag}-${content}`} className="tsd-comment-since">
<Markdown content={content} />
</div>
);
})}
{examples.map(renderTag)}
{rest.map(renderTag)}
</>
);
}
Expand Down
Loading