diff --git a/docs-site/app/docs/[[...slug]]/page.tsx b/docs-site/app/docs/[[...slug]]/page.tsx
index dd5d944c..e0677c9e 100644
--- a/docs-site/app/docs/[[...slug]]/page.tsx
+++ b/docs-site/app/docs/[[...slug]]/page.tsx
@@ -51,10 +51,7 @@ export default async function Page(props: {
<>
{page.data.title}
-
+
{page.data.description}
diff --git a/docs-site/components/docs-page-actions.tsx b/docs-site/components/docs-page-actions.tsx
index 95bf93a4..96d3980b 100644
--- a/docs-site/components/docs-page-actions.tsx
+++ b/docs-site/components/docs-page-actions.tsx
@@ -2,109 +2,37 @@
import { useState } from "react";
-type CopyState = "idle" | "copied" | "error";
-
type Props = {
- markdownUrl: string;
mdxSource: string;
};
-export function DocsPageActions({ markdownUrl, mdxSource }: Props) {
+function stripFrontmatter(source: string) {
+ return source.trim().replace(/^---\n[\s\S]*?\n---\n?/, "").trim();
+}
+
+export function DocsPageActions({ mdxSource }: Props) {
+ const [copied, setCopied] = useState(false);
+
+ const onCopy = async () => {
+ try {
+ await navigator.clipboard.writeText(stripFrontmatter(mdxSource));
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ } catch {
+ // Clipboard denied — fail silently
+ }
+ };
+
return (
-
-
- View MD
-
-
+ {copied ? "Copied" : "Copy as Markdown"}
+
);
}
-
-function CopyMarkdownButton({ markdownUrl }: { markdownUrl: string }) {
- const [state, setState] = useState("idle");
-
- const onClick = async () => {
- try {
- const response = await fetch(markdownUrl, {
- headers: { Accept: "text/markdown" },
- });
-
- if (!response.ok) {
- throw new Error(`Failed to fetch ${markdownUrl}`);
- }
-
- await navigator.clipboard.writeText(await response.text());
- flash(setState, "copied");
- } catch {
- flash(setState, "error");
- }
- };
-
- return (
-
- );
-}
-
-function CopyTextButton({ label, text }: { label: string; text: string }) {
- const [state, setState] = useState("idle");
-
- const onClick = async () => {
- try {
- await navigator.clipboard.writeText(text);
- flash(setState, "copied");
- } catch {
- flash(setState, "error");
- }
- };
-
- return (
-
- );
-}
-
-function ActionButton({
- label,
- onClick,
- state,
-}: {
- label: string;
- onClick: () => void;
- state: CopyState;
-}) {
- return (
-
- );
-}
-
-function labelForState(state: CopyState, label: string) {
- if (state === "copied") return "Copied";
- if (state === "error") return "Copy failed";
- return label;
-}
-
-function flash(
- setState: (state: CopyState) => void,
- state: Exclude,
-) {
- setState(state);
- window.setTimeout(() => setState("idle"), 1500);
-}