File tree Expand file tree Collapse file tree 3 files changed +42
-14
lines changed
Expand file tree Collapse file tree 3 files changed +42
-14
lines changed Original file line number Diff line number Diff line change 11import type { FC , PropsWithChildren } from "hono/jsx" ;
22import type { Page } from "../../types/model" ;
3- import { SiteNoticeBanner , Footer , Breadcrumbs } from "../ui/common/" ;
3+ import {
4+ SiteNoticeBanner ,
5+ Footer ,
6+ Breadcrumbs ,
7+ TableOfContents ,
8+ } from "../ui/common/" ;
49
510export type BaseTemplateProps = PropsWithChildren < {
611 page : Page ;
@@ -397,19 +402,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
397402 ) }
398403 </ main >
399404
400- { outline . length > 0 && (
401- < nav id = "page-overview" >
402- < strong > 目次</ strong >
403- < ul >
404- { outline . map ( ( item , idx ) => (
405- < li data-assoc = { item . id } >
406- < a href = { `#${ item . id } ` } > { item . name } </ a >
407- < ul > </ ul >
408- </ li >
409- ) ) }
410- </ ul >
411- </ nav >
412- ) }
405+ < TableOfContents outline = { outline } />
413406 </ div >
414407
415408 < Footer />
Original file line number Diff line number Diff line change 1+ import type { OutlineItem } from "../../../types/model" ;
2+
3+ export type TableOfContentsProps = {
4+ outline : OutlineItem [ ] ;
5+ } ;
6+
7+ export const TableOfContents = ( { outline } : TableOfContentsProps ) => {
8+ if ( outline . length === 0 ) {
9+ return null ;
10+ }
11+
12+ return (
13+ < nav
14+ id = "page-overview"
15+ class = "flex-none w-full md:w-60 lg:w-72 mt-6 mb-8 px-3.5 py-3 border border-neutral-200/60 rounded-md bg-white sticky top-0 h-screen overflow-auto"
16+ >
17+ < strong class = "block mb-2 text-xs text-neutral-500 font-semibold tracking-wide" >
18+ 目次
19+ </ strong >
20+ < ol class = "space-y-1 text-xs text-neutral-700" >
21+ { outline . map ( ( item ) => (
22+ < li key = { item . id } data-assoc = { item . id } >
23+ < a
24+ href = { `#${ item . id } ` }
25+ class = "block px-2 py-1 rounded hover:bg-neutral-100 transition-colors"
26+ >
27+ { item . name }
28+ </ a >
29+ </ li >
30+ ) ) }
31+ </ ol >
32+ </ nav >
33+ ) ;
34+ } ;
Original file line number Diff line number Diff line change 11export { SiteNoticeBanner } from "./SiteNoticeBanner" ;
22export { Breadcrumbs , type BreadcrumbsProps } from "./Breadcrumbs" ;
3+ export { TableOfContents , type TableOfContentsProps } from "./TableOfContents" ;
34export { Footer } from "./Footer" ;
You can’t perform that action at this time.
0 commit comments