({ frontmatter }: FrontmatterPanelProps)
| 22 | }; |
| 23 | |
| 24 | export function FrontmatterPanel({ frontmatter }: FrontmatterPanelProps) { |
| 25 | const locale = getServerLocale(); |
| 26 | const fm = frontmatter; |
| 27 | const tags = (fm.tags || []) as string[]; |
| 28 | const sources = (fm.sources || []) as string[]; |
| 29 | |
| 30 | return ( |
| 31 | <div className="space-y-3 text-sm"> |
| 32 | <Field label={t("fm.field.title", locale)}> |
| 33 | <span className="font-medium">{fm.title || t("fm.no_title", locale)}</span> |
| 34 | </Field> |
| 35 | <Field label={t("fm.field.type", locale)}> |
| 36 | <Badge variant="outline"> |
| 37 | {tType(fm.type, locale)} |
| 38 | </Badge> |
| 39 | </Field> |
| 40 | <Field label={t("fm.field.status", locale)}> |
| 41 | <Badge variant={STATUS_VARIANT[fm.status || ""] || "secondary"}> |
| 42 | {tStatus(fm.status, locale)} |
| 43 | </Badge> |
| 44 | </Field> |
| 45 | <Field label={t("fm.field.confidence", locale)}> |
| 46 | <Badge variant={CONFIDENCE_VARIANT[fm.confidence || ""] || "secondary"}> |
| 47 | {tConfidence(fm.confidence, locale)} |
| 48 | </Badge> |
| 49 | </Field> |
| 50 | <Field label={t("fm.field.created_date", locale)}> |
| 51 | <span className="font-mono text-xs">{fm.created_date || "—"}</span> |
| 52 | </Field> |
| 53 | <Field label={t("fm.field.last_modified", locale)}> |
| 54 | <span className="font-mono text-xs">{fm.last_modified || "—"}</span> |
| 55 | {fm.last_modified_by && ( |
| 56 | <span className="ml-1 text-xs text-muted-foreground"> |
| 57 | {t("fm.by", locale)} {fm.last_modified_by} |
| 58 | </span> |
| 59 | )} |
| 60 | </Field> |
| 61 | <Field label={t("fm.field.source_count", locale)}> |
| 62 | <span className="font-mono text-xs">{fm.source_count ?? 0}</span> |
| 63 | </Field> |
| 64 | {tags.length > 0 && ( |
| 65 | <Field label={t("fm.field.tags", locale)}> |
| 66 | <div className="flex flex-wrap gap-1"> |
| 67 | {tags.map((tg) => ( |
| 68 | <Badge key={tg} variant="secondary" className="text-[10px]"> |
| 69 | {tg} |
| 70 | </Badge> |
| 71 | ))} |
| 72 | </div> |
| 73 | </Field> |
| 74 | )} |
| 75 | {sources.length > 0 && ( |
| 76 | <Field label={t("fm.field.sources", locale)}> |
| 77 | <ul className="space-y-1 text-xs"> |
| 78 | {sources.map((s, i) => { |
| 79 | // sources 元素是带 [[]] 包裹的 wikilink 字符串。提取目标后用 |
| 80 | // WikiLink 渲染为可点击链接;解析失败则降级显示原文(避免空白) |
| 81 | const links = parseWikilinks(s); |
nothing calls this directly
no test coverage detected