2026-05-19 21:09:56 +08:00
|
|
|
'use client';
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { usePathname } from 'next/navigation';
|
2026-05-21 11:20:01 +08:00
|
|
|
|
|
|
|
|
function cx(...args: (string | false | null | undefined)[]): string {
|
|
|
|
|
return args.filter(Boolean).join(' ');
|
|
|
|
|
}
|
2026-05-19 21:09:56 +08:00
|
|
|
|
|
|
|
|
interface NavItem {
|
2026-05-20 01:30:41 +08:00
|
|
|
label: string;
|
2026-05-19 21:09:56 +08:00
|
|
|
href: string;
|
2026-05-20 01:30:41 +08:00
|
|
|
children?: NavItem[];
|
2026-05-19 21:09:56 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-20 01:30:41 +08:00
|
|
|
const nav: NavItem[] = [
|
2026-05-21 13:38:34 +08:00
|
|
|
{ label: '概览', href: '/' },
|
2026-05-20 01:30:41 +08:00
|
|
|
{ label: '栅格系统', href: '/grid-system' },
|
2026-05-19 21:09:56 +08:00
|
|
|
{
|
2026-05-20 01:30:41 +08:00
|
|
|
label: '布局组件',
|
|
|
|
|
href: '/components/article',
|
|
|
|
|
children: [
|
2026-05-21 13:38:34 +08:00
|
|
|
{ label: 'Layout', href: '/components/article' },
|
|
|
|
|
{ label: 'Section', href: '/components/article' },
|
|
|
|
|
{ label: 'Article', href: '/components/article' },
|
|
|
|
|
{ label: 'Layer', href: '/components/article' },
|
2026-05-20 01:30:41 +08:00
|
|
|
{ label: 'Masthead', href: '/components/masthead' },
|
2026-05-21 13:38:34 +08:00
|
|
|
{ label: 'Rule', href: '/components/rule' },
|
|
|
|
|
{ label: 'Footer', href: '/components/rule' },
|
|
|
|
|
{ label: 'Sidebar', href: '/components/rule' },
|
|
|
|
|
{ label: 'BreakingNewsBanner', href: '/components/rule' },
|
|
|
|
|
{ label: 'Folio', href: '/components/rule' },
|
|
|
|
|
{ label: 'IndexBox', href: '/components/rule' },
|
|
|
|
|
{ label: 'Factbox', href: '/components/rule' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '文本组件',
|
|
|
|
|
href: '/text',
|
|
|
|
|
children: [
|
|
|
|
|
{ label: 'Headline', href: '/text' },
|
|
|
|
|
{ label: 'Subhead', href: '/text' },
|
|
|
|
|
{ label: 'Kicker', href: '/text' },
|
|
|
|
|
{ label: 'BodyText', href: '/text' },
|
|
|
|
|
{ label: 'Quote', href: '/text' },
|
|
|
|
|
{ label: 'Byline', href: '/text' },
|
|
|
|
|
{ label: 'Dateline', href: '/text' },
|
|
|
|
|
{ label: 'Caption', href: '/text' },
|
|
|
|
|
{ label: 'AuthorCard', href: '/text' },
|
|
|
|
|
{ label: 'JumpLine', href: '/text' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '媒体组件',
|
|
|
|
|
href: '/components/media',
|
|
|
|
|
children: [
|
|
|
|
|
{ label: 'Image', href: '/components/media' },
|
|
|
|
|
{ label: 'Figure', href: '/components/media' },
|
|
|
|
|
{ label: 'Video', href: '/components/media' },
|
|
|
|
|
{ label: 'PullQuote', href: '/components/media' },
|
|
|
|
|
{ label: 'RelatedArticles', href: '/components/media' },
|
2026-05-19 21:09:56 +08:00
|
|
|
],
|
|
|
|
|
},
|
2026-05-20 01:30:41 +08:00
|
|
|
{ label: '主题与颜色', href: '/theme' },
|
2026-05-21 13:38:34 +08:00
|
|
|
{ label: 'Create 主题', href: '/create' },
|
|
|
|
|
{ label: 'Blocks', href: '/blocks' },
|
2026-05-19 21:09:56 +08:00
|
|
|
{
|
2026-05-20 01:30:41 +08:00
|
|
|
label: '示例',
|
|
|
|
|
href: '/examples/spanning',
|
|
|
|
|
children: [
|
|
|
|
|
{ label: '跨栏布局', href: '/examples/spanning' },
|
|
|
|
|
{ label: '响应式', href: '/examples/responsive' },
|
2026-05-21 13:38:34 +08:00
|
|
|
{ label: 'NYT 头版', href: '/examples/nyt-frontpage' },
|
|
|
|
|
{ label: 'Blackletter', href: '/examples/blackletter-frontpage' },
|
2026-05-19 21:09:56 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function Sidebar() {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
return (
|
2026-05-20 01:30:41 +08:00
|
|
|
<aside
|
|
|
|
|
style={{
|
|
|
|
|
width: '240px',
|
|
|
|
|
flexShrink: 0,
|
|
|
|
|
padding: '2rem 1rem',
|
|
|
|
|
borderRight: '1px solid var(--nui-rule-hairline)',
|
|
|
|
|
background: 'var(--nui-bg-surface)',
|
|
|
|
|
fontFamily: 'var(--font-family-meta)',
|
|
|
|
|
fontSize: '14px',
|
|
|
|
|
position: 'sticky',
|
2026-05-20 14:22:14 +08:00
|
|
|
top: 65,
|
2026-05-20 01:30:41 +08:00
|
|
|
alignSelf: 'flex-start',
|
2026-05-20 14:22:14 +08:00
|
|
|
maxHeight: 'calc(100vh - 65px)',
|
2026-05-20 01:30:41 +08:00
|
|
|
overflowY: 'auto',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Link
|
|
|
|
|
href="/"
|
|
|
|
|
style={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
fontFamily: 'var(--font-family-masthead)',
|
|
|
|
|
fontSize: '22px',
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
color: 'var(--nui-text-primary)',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
marginBottom: '0.25rem',
|
|
|
|
|
letterSpacing: '0.02em',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
NewspaperUI
|
|
|
|
|
</Link>
|
|
|
|
|
<div
|
|
|
|
|
className="nui-small-caps"
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: '11px',
|
|
|
|
|
color: 'var(--nui-text-muted)',
|
|
|
|
|
marginBottom: '2rem',
|
|
|
|
|
letterSpacing: '0.08em',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Production Newspaper Components
|
2026-05-19 21:09:56 +08:00
|
|
|
</div>
|
|
|
|
|
|
2026-05-20 01:30:41 +08:00
|
|
|
<nav>
|
|
|
|
|
<ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
|
|
|
|
|
{nav.map((item) => (
|
|
|
|
|
<li key={item.href} style={{ marginBottom: '0.75rem' }}>
|
|
|
|
|
<Link
|
|
|
|
|
href={item.href}
|
|
|
|
|
className={cx(pathname === item.href && 'active')}
|
|
|
|
|
style={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
padding: '0.25rem 0',
|
|
|
|
|
color:
|
|
|
|
|
pathname === item.href
|
|
|
|
|
? 'var(--nui-accent-primary)'
|
|
|
|
|
: 'var(--nui-text-secondary)',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
fontWeight: pathname === item.href ? 600 : 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{item.label}
|
|
|
|
|
</Link>
|
|
|
|
|
{item.children && (
|
|
|
|
|
<ul style={{ listStyle: 'none', padding: '0 0 0 1rem', margin: '0.25rem 0 0' }}>
|
|
|
|
|
{item.children.map((child) => (
|
|
|
|
|
<li key={child.href} style={{ marginBottom: '0.25rem' }}>
|
|
|
|
|
<Link
|
|
|
|
|
href={child.href}
|
|
|
|
|
style={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
padding: '0.15rem 0',
|
|
|
|
|
fontSize: '13px',
|
|
|
|
|
color:
|
|
|
|
|
pathname === child.href
|
|
|
|
|
? 'var(--nui-accent-primary)'
|
|
|
|
|
: 'var(--nui-text-muted)',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
fontWeight: pathname === child.href ? 600 : 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{child.label}
|
|
|
|
|
</Link>
|
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
)}
|
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
</nav>
|
|
|
|
|
</aside>
|
2026-05-19 21:09:56 +08:00
|
|
|
);
|
|
|
|
|
}
|