Skip to content

Commit a55630c

Browse files
committed
feat: move Copy page button to H1 header row
Move the "Copy page" dropdown from the TOC sidebar into the main content area, inline with the page H1. The button is right-aligned in a flex header row using <header> (not <div>) to avoid the markdown-body CSS column override. The dropdown panel is now absolutely positioned so it floats over content without shifting layout.
1 parent ad1de88 commit a55630c

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

_components/CopyPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function CopyPage({ file }: { file: string | undefined }) {
99
}`;
1010

1111
return (
12-
<details class="copy-page-dropdown">
12+
<details class="copy-page-dropdown relative">
1313
<summary class="btn list-none [&::-webkit-details-marker]:hidden flex items-center gap-2 cursor-pointer select-none">
1414
<svg
1515
xmlns="http://www.w3.org/2000/svg"
@@ -36,7 +36,7 @@ export default function CopyPage({ file }: { file: string | undefined }) {
3636
</svg>
3737
</summary>
3838

39-
<div class="mt-2 border border-foreground-tertiary rounded-md overflow-hidden bg-white dark:bg-gray-900">
39+
<div class="absolute right-0 z-50 mt-1 w-72 border border-foreground-tertiary rounded-md overflow-hidden bg-white dark:bg-gray-900 shadow-lg">
4040
<button class="copy-page-link-btn flex items-start gap-3 w-full px-4 py-3 text-left hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors">
4141
<svg
4242
xmlns="http://www.w3.org/2000/svg"
@@ -62,7 +62,7 @@ export default function CopyPage({ file }: { file: string | undefined }) {
6262
<a
6363
href={file}
6464
target="_blank"
65-
class="flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors"
65+
class="no-underline flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors"
6666
>
6767
<svg
6868
xmlns="http://www.w3.org/2000/svg"
@@ -86,7 +86,7 @@ export default function CopyPage({ file }: { file: string | undefined }) {
8686
<a
8787
href={claudeUrl}
8888
target="_blank"
89-
class="flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors"
89+
class="no-underline flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors"
9090
>
9191
<svg
9292
xmlns="http://www.w3.org/2000/svg"

_components/TableOfContents.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
import type { TableOfContentsItem as TableOfContentsItem_ } from "../types.ts";
22

3-
export default function TableOfContents({ data, toc, hasSubNav, file }: {
3+
export default function TableOfContents({ data, toc, hasSubNav }: {
44
data: Lume.Data;
55
toc: TableOfContentsItem_[];
66
hasSubNav: boolean;
7-
file?: string;
87
}) {
98
if (!toc || toc.length === 0) {
109
return null;
1110
}
1211
const topClasses = hasSubNav ? "top-header-plus-subnav" : "top-header";
1312

1413
return (
15-
<div
16-
className={`hidden sticky ${topClasses} h-screen-minus-header border-l border-l-foreground-tertiary lg:flex lg:flex-col lg:w-full`}
14+
<ul
15+
className={`toc-list hidden sticky ${topClasses} h-screen-minus-header overflow-y-auto border-l border-l-foreground-tertiary p-4 pr-0 lg:flex lg:flex-col lg:w-full`}
16+
id="toc"
1717
>
18-
{file && !file.includes("[") && (
19-
<div class="px-4 pt-4 shrink-0">
20-
<data.comp.CopyPage file={file} />
21-
</div>
22-
)}
23-
<ul
24-
className="toc-list overflow-y-auto flex-1 p-4 pr-0"
25-
id="toc"
26-
>
27-
{toc.map((item: TableOfContentsItem_) => (
28-
<data.comp.TableOfContentsItem item={item} />
29-
))}
30-
</ul>
31-
</div>
18+
{toc.map((item: TableOfContentsItem_) => (
19+
<data.comp.TableOfContentsItem item={item} />
20+
))}
21+
</ul>
3222
);
3323
}

_includes/doc.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ export default function Doc(data: Lume.Data, helpers: Lume.Helpers) {
6969
class="markdown-body mt-6 sm:mt-6"
7070
>
7171
{!(isReference && !isApiLandingPage) && (
72-
<h1
73-
dangerouslySetInnerHTML={{
74-
__html: helpers.md(data.title!, true),
75-
}}
76-
>
77-
</h1>
72+
<header class="flex items-start justify-between gap-4">
73+
<h1
74+
dangerouslySetInnerHTML={{
75+
__html: helpers.md(data.title!, true),
76+
}}
77+
>
78+
</h1>
79+
{file && !file.includes("[") && file.endsWith(".md") && (
80+
<data.comp.CopyPage file={file} />
81+
)}
82+
</header>
7883
)}
7984
{data.available_since && (
8085
<div class="bg-gray-200 rounded-md text-sm py-3 px-4 mb-4 font-semibold">

_includes/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export default function Layout(data: Lume.Data) {
120120
toc={data.toc}
121121
data={data}
122122
hasSubNav={hasSubNav}
123-
file={data.page?.sourcePath}
124123
/>
125124
)}
126125
</div>

0 commit comments

Comments
 (0)