1- import * as React from 'react'
2- import { FaEdit } from 'react-icons/fa'
3- import { marked } from 'marked'
4- import markedAlert from 'marked-alert'
5- import { gfmHeadingId , getHeadingList } from 'marked-gfm-heading-id'
61import { DocTitle } from '~/components/DocTitle'
72import { Markdown } from '~/components/Markdown'
8- import { Toc } from './Toc'
3+ import { marked } from 'marked'
4+ import markedAlert from 'marked-alert'
5+ import { getHeadingList , gfmHeadingId } from 'marked-gfm-heading-id'
6+ import * as React from 'react'
7+ import { FaEdit } from 'react-icons/fa'
98import { twMerge } from 'tailwind-merge'
10- import { TocMobile } from './TocMobile'
119import { GadLeader } from './GoogleScripts'
10+ import { Toc } from './Toc'
11+ import { TocMobile } from './TocMobile'
1212
1313type DocProps = {
14+ isBlog ?: boolean
1415 title : string
1516 content : string
1617 repo : string
@@ -22,6 +23,7 @@ type DocProps = {
2223}
2324
2425export function Doc ( {
26+ isBlog = false ,
2527 title,
2628 content,
2729 repo,
@@ -35,7 +37,7 @@ export function Doc({
3537 const markup = marked . use (
3638 { gfm : true } ,
3739 gfmHeadingId ( ) ,
38- markedAlert ( )
40+ markedAlert ( ) ,
3941 ) ( content ) as string
4042
4143 const headings = getHeadingList ( )
@@ -59,7 +61,7 @@ export function Doc({
5961 map [ headingElement . target . id ] = headingElement
6062 return map
6163 } ,
62- headingElementRefs . current
64+ headingElementRefs . current ,
6365 )
6466
6567 const visibleHeadings : Array < IntersectionObserverEntry > = [ ]
@@ -82,8 +84,8 @@ export function Doc({
8284
8385 const headingElements = Array . from (
8486 markdownContainerRef . current ?. querySelectorAll (
85- 'h2[id], h3[id], h4[id], h5[id], h6[id]'
86- ) ?? [ ]
87+ 'h2[id], h3[id], h4[id], h5[id], h6[id]' ,
88+ ) ?? [ ] ,
8789 )
8890 headingElements . forEach ( ( el ) => observer . observe ( el ) )
8991
@@ -95,34 +97,34 @@ export function Doc({
9597 { shouldRenderToc ? < TocMobile headings = { headings } /> : null }
9698 < div
9799 className = { twMerge (
98- 'w-full flex bg-white/70 dark:bg-black/40 mx-auto rounded-xl max-w-[936px] ' ,
100+ 'mx-auto flex w-full bg-white/70 dark:bg-black/40' ,
99101 isTocVisible && 'max-w-full' ,
100- shouldRenderToc && 'lg:pt-0'
102+ shouldRenderToc && 'lg:pt-0' ,
101103 ) }
102104 >
103105 < div
104106 className = { twMerge (
105- 'flex overflow -auto flex-col w-full p-4 lg:p-6 ' ,
106- isTocVisible && '!pr-0'
107+ 'ml -auto flex w-full max-w-[820px] flex-col overflow-auto p-4.5 ' ,
108+ isBlog && 'mx-auto' ,
107109 ) }
108110 >
109111 < GadLeader />
110112 { title ? < DocTitle > { title } </ DocTitle > : null }
111113 < div className = "h-4" />
112- < div className = "h-px bg-gray-500 opacity- 20" />
114+ < div className = "h-px bg-gray-500/ 20" />
113115 < div className = "h-4" />
114116 < div
115117 ref = { markdownContainerRef }
116118 className = { twMerge (
117119 'prose prose-gray prose-sm prose-p:leading-7 dark:prose-invert max-w-none' ,
118120 isTocVisible && 'pr-4 lg:pr-6' ,
119- 'styled-markdown-content'
121+ 'styled-markdown-content' ,
120122 ) }
121123 >
122124 < Markdown htmlMarkup = { markup } />
123125 </ div >
124126 < div className = "h-12" />
125- < div className = "w-full h-px bg-gray-500 opacity-30" />
127+ < div className = "h-px w-full bg-gray-500 opacity-30" />
126128 < div className = "py-4 opacity-70" >
127129 < a
128130 href = { `https://github.com/${ repo } /edit/${ branch } /${ filePath } ` }
@@ -134,15 +136,22 @@ export function Doc({
134136 < div className = "h-24" />
135137 </ div >
136138
137- { isTocVisible && (
138- < div className = "border-l border-gray-500/20 max-w-52 w-full hidden 2xl:block transition-all " >
139+ { isTocVisible ? (
140+ < div className = "hidden w-full max-w-64 border-l border-gray-500/20 transition-all 2xl:block" >
139141 < Toc
140142 headings = { headings }
141143 activeHeadings = { activeHeadings }
142144 colorFrom = { colorFrom }
143145 colorTo = { colorTo }
144146 />
145147 </ div >
148+ ) : (
149+ < div
150+ className = { twMerge (
151+ 'hidden w-full max-w-64 2xl:block' ,
152+ isBlog && '2xl:hidden' ,
153+ ) }
154+ />
146155 ) }
147156 </ div >
148157 </ React . Fragment >
0 commit comments