File tree Expand file tree Collapse file tree 1 file changed +25
-12
lines changed
website/src/components/ui/common Expand file tree Collapse file tree 1 file changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,30 @@ export type TableOfContentsProps = {
44 outline : OutlineItem [ ] ;
55} ;
66
7+ const PlainTableOfContents = ( {
8+ outline,
9+ topLevel = false ,
10+ } : TableOfContentsProps & { topLevel ?: boolean } ) => {
11+ return (
12+ // Indent for succedding levels
13+ < ol class = { `space-y-1 ${ ! topLevel && "pl-4" } text-sm text-neutral-700` } >
14+ { outline . map ( ( item ) => (
15+ < li key = { item . id } data-assoc = { item . id } >
16+ < a
17+ href = { `#${ item . id } ` }
18+ class = "block px-2 py-1 rounded hover:bg-neutral-100 transition-colors"
19+ >
20+ { item . name }
21+ </ a >
22+ { item . children . length > 0 && (
23+ < PlainTableOfContents outline = { item . children } />
24+ ) }
25+ </ li >
26+ ) ) }
27+ </ ol >
28+ ) ;
29+ } ;
30+
731export const TableOfContents = ( { outline } : TableOfContentsProps ) => {
832 if ( outline . length === 0 ) {
933 return null ;
@@ -17,18 +41,7 @@ export const TableOfContents = ({ outline }: TableOfContentsProps) => {
1741 < strong class = "block mb-2 text-sm text-neutral-500 font-semibold tracking-wide" >
1842 目次
1943 </ strong >
20- < ol class = "space-y-1 text-sm 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 >
44+ < PlainTableOfContents outline = { outline } topLevel = { true } />
3245 </ nav >
3346 ) ;
3447} ;
You can’t perform that action at this time.
0 commit comments