@@ -91,9 +91,12 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
9191 } ;
9292 } ;
9393
94- const buttonClass = "inline-flex items-center h-full text-gray-700 dark:text-[var(--foreground)] bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-[var(--gray-a4)] active:bg-gray-100 dark:active:bg-[var(--gray-5)] focus:bg-gray-50 dark:focus:bg-[var(--gray-a4)] outline-none" ;
95- const dropdownItemClass = "flex items-center gap-3 w-full p-2 px-3 text-left bg-transparent rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-[var(--gray-a4)] font-sans text-gray-900 dark:text-[var(--foreground)]" ;
96- const iconContainerClass = "flex items-center justify-center w-7 h-7 bg-gray-100 dark:bg-[var(--gray-a4)] rounded shrink-0" ;
94+ const buttonClass =
95+ 'inline-flex items-center h-full text-gray-700 dark:text-[var(--foreground)] bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-[var(--gray-a4)] active:bg-gray-100 dark:active:bg-[var(--gray-5)] focus:bg-gray-50 dark:focus:bg-[var(--gray-a4)] outline-none' ;
96+ const dropdownItemClass =
97+ 'flex items-center gap-3 w-full p-2 px-3 text-left bg-transparent rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-[var(--gray-a4)] font-sans text-gray-900 dark:text-[var(--foreground)]' ;
98+ const iconContainerClass =
99+ 'flex items-center justify-center w-7 h-7 bg-gray-100 dark:bg-[var(--gray-a4)] rounded shrink-0' ;
97100
98101 return (
99102 < Fragment >
@@ -126,50 +129,58 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
126129 </ div >
127130 </ div >
128131
129- { isMounted && isOpen && createPortal (
130- < div
131- ref = { dropdownRef }
132- className = "fixed w-80 bg-white dark:bg-[var(--gray-2)] rounded-xl shadow-lg overflow-hidden z-[9999] border border-gray-300 dark:border-[var(--gray-6)]"
133- style = { { ...getDropdownPosition ( ) } }
134- >
135- < div className = "p-1" >
136- < button
137- onClick = { copyMarkdownToClipboard }
138- className = { `${ dropdownItemClass } border-none cursor-pointer disabled:opacity-50` }
139- disabled = { isLoading }
140- >
141- < div className = { iconContainerClass } >
142- < Clipboard size = { 14 } />
143- </ div >
144- < div className = "flex-1" >
145- < div className = { `font-medium text-sm leading-5` } >
146- { error ? 'Failed to copy' : 'Copy page' }
132+ { isMounted &&
133+ isOpen &&
134+ createPortal (
135+ < div
136+ ref = { dropdownRef }
137+ className = "fixed w-80 bg-white dark:bg-[var(--gray-2)] rounded-xl shadow-lg overflow-hidden z-[9999] border border-gray-300 dark:border-[var(--gray-6)]"
138+ style = { { ...getDropdownPosition ( ) } }
139+ >
140+ < div className = "p-1" >
141+ < button
142+ onClick = { copyMarkdownToClipboard }
143+ className = { `${ dropdownItemClass } border-none cursor-pointer disabled:opacity-50` }
144+ disabled = { isLoading }
145+ >
146+ < div className = { iconContainerClass } >
147+ < Clipboard size = { 14 } />
148+ </ div >
149+ < div className = "flex-1" >
150+ < div className = { `font-medium text-sm leading-5` } >
151+ { error ? 'Failed to copy' : 'Copy page' }
152+ </ div >
153+ < div className = "text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]" >
154+ { error
155+ ? 'Network error - please try again'
156+ : 'Copy page as Markdown for LLMs' }
157+ </ div >
158+ </ div >
159+ </ button >
160+
161+ < Link
162+ href = { `/${ pathname } .md` }
163+ target = "_blank"
164+ rel = "noopener noreferrer"
165+ className = { `${ dropdownItemClass } no-underline` }
166+ onClick = { handleViewMarkdownClick }
167+ >
168+ < div className = { iconContainerClass } >
169+ < Markdown width = { 14 } height = { 14 } />
147170 </ div >
148- < div className = "text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]" >
149- { error ? 'Network error - please try again' : 'Copy page as Markdown for LLMs' }
171+ < div className = "flex-1" >
172+ < div className = "font-medium text-sm leading-5 text-gray-900 dark:text-[var(--foreground)]" >
173+ View as Markdown
174+ </ div >
175+ < div className = "text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]" >
176+ View this page as plain text
177+ </ div >
150178 </ div >
151- </ div >
152- </ button >
153-
154- < Link
155- href = { `/${ pathname } .md` }
156- target = "_blank"
157- rel = "noopener noreferrer"
158- className = { `${ dropdownItemClass } no-underline` }
159- onClick = { handleViewMarkdownClick }
160- >
161- < div className = { iconContainerClass } >
162- < Markdown width = { 14 } height = { 14 } />
163- </ div >
164- < div className = "flex-1" >
165- < div className = "font-medium text-sm leading-5 text-gray-900 dark:text-[var(--foreground)]" > View as Markdown</ div >
166- < div className = "text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]" > View this page as plain text</ div >
167- </ div >
168- </ Link >
169- </ div >
170- </ div > ,
171- document . body
172- ) }
179+ </ Link >
180+ </ div >
181+ </ div > ,
182+ document . body
183+ ) }
173184 </ Fragment >
174185 ) ;
175186}
0 commit comments