import { Breadcrumb, Card, Paragraph, Text, Title } from '@stash/ui' import type { ArticleItem } from '../../data/types' import { viewPath } from '../../data/view' import { ArticleBody } from './ArticleBody' /** * 文章详情页(对应模板图二): * 面包屑 + 大标题 + [编辑] + 元信息行 + 白色正文卡。 * * 正文是一整段 Markdown,交给 ArticleBody 解析渲染; * 渲染细节(支持哪些语法)都收在那一个组件里。 */ type ArticleDetailViewProps = { article: ArticleItem categoryId: string categoryTitle: string onNavigate: (href: string) => void onEdit: () => void /** 只有登录后才显示 [编辑] */ canEdit: boolean } export function ArticleDetailView({ article, categoryId, categoryTitle, onNavigate, onEdit, canEdit, }: ArticleDetailViewProps) { const meta = article.meta ?? ['2 年前', categoryTitle] const crumbs = [ { label: '首页', href: '/' }, { label: categoryTitle, href: viewPath({ type: 'detail', categoryId }) }, { label: '文章' }, ] return (
{article.title} {canEdit && ( <button type="button" className="item-edit" title="编辑文章" onClick={onEdit}> [编辑] </button> )}
{meta.map((text, index) => ( {index > 0 &&