feat(polaris): 实现静态分类页
新增七个预生成分类路由、工具卡片网格与空状态。启用侧栏分类导航和当前分类选中态,修复 Windows 静态导出 RSC 路径并补充产物验证,保持静态导出与安全外链约束。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ type SidebarProps = {
|
||||
categories: Category[]
|
||||
siteName: string
|
||||
collapsed: boolean
|
||||
activeCategoryId?: string
|
||||
onToggle: () => void
|
||||
}
|
||||
|
||||
@@ -24,10 +25,12 @@ export function Sidebar({
|
||||
categories,
|
||||
siteName,
|
||||
collapsed,
|
||||
activeCategoryId,
|
||||
onToggle,
|
||||
}: SidebarProps) {
|
||||
const ToggleIcon = collapsed ? PanelLeftOpen : PanelLeftClose
|
||||
const toggleLabel = collapsed ? "展开侧边栏" : "折叠侧边栏"
|
||||
const homeIsActive = activeCategoryId === undefined
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
@@ -62,9 +65,12 @@ export function Sidebar({
|
||||
|
||||
<nav className="sidebar__nav" aria-label="站点导航">
|
||||
<Link
|
||||
className="sidebar__nav-item sidebar__nav-item--active"
|
||||
className={cn(
|
||||
"sidebar__nav-item",
|
||||
homeIsActive && "sidebar__nav-item--active",
|
||||
)}
|
||||
href="/"
|
||||
aria-current="page"
|
||||
aria-current={homeIsActive ? "page" : undefined}
|
||||
>
|
||||
<Home aria-hidden="true" />
|
||||
<span className={cn("sidebar__label", collapsed && "sr-only")}>
|
||||
@@ -73,30 +79,32 @@ export function Sidebar({
|
||||
</Link>
|
||||
|
||||
<div className="sidebar__categories">
|
||||
{/* 本次只验收首页;分类页完成前保持可见但禁用,避免用户进入 404。 */}
|
||||
{categories.map((category) => (
|
||||
<Tooltip key={category.id}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className="sidebar__nav-item"
|
||||
aria-disabled="true"
|
||||
aria-label={`${category.title},分类页将在下一阶段提供`}
|
||||
>
|
||||
<CategoryIcon name={category.icon} />
|
||||
<span
|
||||
className={cn("sidebar__label", collapsed && "sr-only")}
|
||||
{categories.map((category) => {
|
||||
const isActive = category.id === activeCategoryId
|
||||
|
||||
return (
|
||||
<Tooltip key={category.id}>
|
||||
<TooltipTrigger asChild>
|
||||
<Link
|
||||
className={cn(
|
||||
"sidebar__nav-item",
|
||||
isActive && "sidebar__nav-item--active",
|
||||
)}
|
||||
href={`/categories/${category.id}`}
|
||||
aria-current={isActive ? "page" : undefined}
|
||||
>
|
||||
{category.title}
|
||||
</span>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
分类页将在下一阶段提供
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
))}
|
||||
<CategoryIcon name={category.icon} />
|
||||
<span
|
||||
className={cn("sidebar__label", collapsed && "sr-only")}
|
||||
>
|
||||
{category.title}
|
||||
</span>
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{category.title}</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user