@@ -7,6 +7,7 @@ import { DocTitle } from '~/components/DocTitle'
77import { Markdown } from '~/components/Markdown'
88import { Toc } from './Toc'
99import { twMerge } from 'tailwind-merge'
10+ import { TocMobile } from './TocMobile'
1011
1112type DocProps = {
1213 title : string
@@ -89,55 +90,59 @@ export function Doc({
8990 } , [ ] )
9091
9192 return (
92- < div
93- className = { twMerge (
94- 'w-full flex bg-white/70 dark:bg-black/40 mx-auto rounded-xl max-w-[936px]' ,
95- isTocVisible && 'max-w-full'
96- ) }
97- >
93+ < React . Fragment >
94+ { shouldRenderToc ? < TocMobile headings = { headings } /> : null }
9895 < div
9996 className = { twMerge (
100- 'flex overflow-auto flex-col w-full p-4 lg:p-6' ,
101- isTocVisible && '!pr-0'
97+ 'w-full flex bg-white/70 dark:bg-black/40 mx-auto rounded-xl max-w-[936px]' ,
98+ isTocVisible && 'max-w-full' ,
99+ shouldRenderToc && 'lg:pt-0'
102100 ) }
103101 >
104- { title ? < DocTitle > { title } </ DocTitle > : null }
105- < div className = "h-4" />
106- < div className = "h-px bg-gray-500 opacity-20" />
107- < div className = "h-4" />
108102 < div
109- ref = { markdownContainerRef }
110103 className = { twMerge (
111- 'prose prose-gray prose-sm prose-p:leading-7 dark:prose-invert max-w-none' ,
112- isTocVisible && 'pr-4 lg:pr-6' ,
113- 'styled-markdown-content'
104+ 'flex overflow-auto flex-col w-full p-4 lg:p-6' ,
105+ isTocVisible && '!pr-0'
114106 ) }
115107 >
116- < Markdown htmlMarkup = { markup } />
117- </ div >
118- < div className = "h-12" />
119- < div className = "w-full h-px bg-gray-500 opacity-30" />
120- < div className = "py-4 opacity-70" >
121- < a
122- href = { `https://github.com/${ repo } /tree/${ branch } /${ filePath } ` }
123- className = "flex items-center gap-2"
108+ { title ? < DocTitle > { title } </ DocTitle > : null }
109+ < div className = "h-4" />
110+ < div className = "h-px bg-gray-500 opacity-20" />
111+ < div className = "h-4" />
112+ < div
113+ ref = { markdownContainerRef }
114+ className = { twMerge (
115+ 'prose prose-gray prose-sm prose-p:leading-7 dark:prose-invert max-w-none' ,
116+ isTocVisible && 'pr-4 lg:pr-6' ,
117+ 'styled-markdown-content'
118+ ) }
124119 >
125- < FaEdit /> Edit on GitHub
126- </ a >
120+ < Markdown htmlMarkup = { markup } />
121+ </ div >
122+ < div className = "h-12" />
123+ < div className = "w-full h-px bg-gray-500 opacity-30" />
124+ < div className = "py-4 opacity-70" >
125+ < a
126+ href = { `https://github.com/${ repo } /tree/${ branch } /${ filePath } ` }
127+ className = "flex items-center gap-2"
128+ >
129+ < FaEdit /> Edit on GitHub
130+ </ a >
131+ </ div >
132+ < div className = "h-24" />
127133 </ div >
128- < div className = "h-24" />
129- </ div >
130134
131- { isTocVisible && (
132- < div className = "border-l border-gray-500/20 max-w-52 w-full hidden 2xl:block transition-all" >
133- < Toc
134- headings = { headings }
135- activeHeadings = { activeHeadings }
136- colorFrom = { colorFrom }
137- colorTo = { colorTo }
138- />
139- </ div >
140- ) }
141- </ div >
135+ { isTocVisible && (
136+ < div className = "border-l border-gray-500/20 max-w-52 w-full hidden 2xl:block transition-all" >
137+ < Toc
138+ headings = { headings }
139+ activeHeadings = { activeHeadings }
140+ colorFrom = { colorFrom }
141+ colorTo = { colorTo }
142+ />
143+ </ div >
144+ ) }
145+ </ div >
146+ </ React . Fragment >
142147 )
143148}
0 commit comments