123
This commit is contained in:
@@ -38,11 +38,11 @@ export default async function DocPage({ params }: { params: Promise<{ slug: stri
|
||||
|
||||
return (
|
||||
<article className="doc-page-container">
|
||||
<h1 className="text-4xl font-bold mb-4">{doc.meta.title}</h1>
|
||||
{doc.meta.description && (
|
||||
<p className="text-xl text-gray-500 dark:text-gray-400 mb-8">{doc.meta.description}</p>
|
||||
<h1 className="doc-page-title">{doc!.meta.title}</h1>
|
||||
{doc!.meta.description && (
|
||||
<p className="doc-page-description">{doc!.meta.description}</p>
|
||||
)}
|
||||
<DocContent contentHtml={doc.contentHtml} />
|
||||
<DocContent contentHtml={doc!.contentHtml} />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
103
app/globals.css
103
app/globals.css
@@ -114,6 +114,68 @@ body {
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* Theme Toggle Button */
|
||||
.theme-toggle {
|
||||
background: transparent;
|
||||
border: 1px solid var(--border-color);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
border-radius: 9999px;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border-color: var(--text-muted);
|
||||
box-shadow: 0 0 10px var(--accent-glow);
|
||||
}
|
||||
|
||||
.theme-toggle-icon-wrapper {
|
||||
position: relative;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.theme-toggle-sun,
|
||||
.theme-toggle-moon {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
/* Light Mode State */
|
||||
.theme-toggle.is-light .theme-toggle-sun {
|
||||
opacity: 1;
|
||||
transform: rotate(0deg) scale(1);
|
||||
}
|
||||
|
||||
.theme-toggle.is-light .theme-toggle-moon {
|
||||
opacity: 0;
|
||||
transform: rotate(90deg) scale(0);
|
||||
}
|
||||
|
||||
/* Dark Mode State */
|
||||
.theme-toggle.is-dark .theme-toggle-sun {
|
||||
opacity: 0;
|
||||
transform: rotate(-90deg) scale(0);
|
||||
}
|
||||
|
||||
.theme-toggle.is-dark .theme-toggle-moon {
|
||||
opacity: 1;
|
||||
transform: rotate(0deg) scale(1);
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
@@ -166,9 +228,16 @@ body {
|
||||
}
|
||||
|
||||
.sidebar-section-arrow {
|
||||
font-size: 0.6rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text-muted);
|
||||
transition: transform 0.2s ease;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.sidebar-section-arrow svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
}
|
||||
|
||||
.sidebar-section-arrow.open {
|
||||
@@ -210,6 +279,30 @@ body {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* --- DocPage container and hero --- */
|
||||
.doc-page-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.doc-page-title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 800;
|
||||
color: var(--text-primary);
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1.2;
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
.doc-page-description {
|
||||
font-size: 1.125rem;
|
||||
color: var(--text-muted);
|
||||
margin: 0 0 2.5rem 0;
|
||||
line-height: 1.6;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* --- DocContent (Markdown) Styles --- */
|
||||
.doc-article {
|
||||
color: var(--text-primary);
|
||||
@@ -365,10 +458,4 @@ body {
|
||||
border: 0;
|
||||
border-top: 1px solid var(--border-color);
|
||||
margin: 3rem 0;
|
||||
}
|
||||
|
||||
/* Title container wrapper inside article to strip Tailwind prose max-width constraint */
|
||||
article {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -60,7 +60,11 @@ export function Sidebar({ sidebarData, currentSlug }: SidebarProps) {
|
||||
onClick={() => toggleSection(item.slug)}
|
||||
>
|
||||
{item.title}
|
||||
<span className={`sidebar-section-arrow ${isOpen ? 'open' : ''}`}>▶</span>
|
||||
<span className={`sidebar-section-arrow ${isOpen ? 'open' : ''}`}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="m9 18 6-6-6-6" />
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
{isOpen && (
|
||||
<div className="sidebar-section-children">
|
||||
|
||||
@@ -19,11 +19,28 @@ export function ThemeToggle() {
|
||||
return (
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
className="theme-toggle"
|
||||
className={`theme-toggle ${theme === 'light' ? 'is-light' : 'is-dark'}`}
|
||||
title={theme === 'light' ? '切换到深色模式' : '切换到亮色模式'}
|
||||
aria-label="Toggle theme"
|
||||
>
|
||||
{theme === 'light' ? '🌙' : '☀️'}
|
||||
<div className="theme-toggle-icon-wrapper">
|
||||
{/* Sun Icon */}
|
||||
<svg className="theme-toggle-sun" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx="12" cy="12" r="4"></circle>
|
||||
<path d="M12 2v2"></path>
|
||||
<path d="M12 20v2"></path>
|
||||
<path d="M4.93 4.93l1.41 1.41"></path>
|
||||
<path d="M17.66 17.66l1.41 1.41"></path>
|
||||
<path d="M2 12h2"></path>
|
||||
<path d="M20 12h2"></path>
|
||||
<path d="M4.93 19.07l1.41-1.41"></path>
|
||||
<path d="M17.66 6.34l1.41-1.41"></path>
|
||||
</svg>
|
||||
{/* Moon Icon */}
|
||||
<svg className="theme-toggle-moon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,11 +98,16 @@ export const getDocBySlug = cache(async (slug: string[]): Promise<DocPage | null
|
||||
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||||
const { data, content } = matter(fileContent);
|
||||
|
||||
// Strip the first H1 heading from the markdown body since the page component
|
||||
// renders the title separately from meta.title. gray-matter may leave leading
|
||||
// newlines in content, so we trim the left first before matching.
|
||||
const contentWithoutH1 = content.replace(/^\s*#[^\n]*\n+/, '');
|
||||
|
||||
// Process markdown
|
||||
const processedContent = await remark()
|
||||
.use(remarkGfm)
|
||||
.use(html, { sanitize: false })
|
||||
.process(content);
|
||||
.process(contentWithoutH1);
|
||||
|
||||
let contentHtml = processedContent.toString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user