fix(site): strip trailing slashes from pathname when copying markdown

also: more work on $483
This commit is contained in:
Darius Cepulis
2026-02-13 08:09:26 -06:00
parent 0d0fa61d7b
commit 493fc2bcd5
+4 -2
View File
@@ -25,7 +25,9 @@ export default function CopyMarkdownButton({ className, style }: CopyMarkdownBut
setState({ status: 'loading' });
// Get current pathname and construct markdown URL
const pathname = window.location.pathname;
// Strip trailing slashes so `/guide/` becomes `/guide.md`, not `/guide/.md`
// Astro should forbid trailing slashes, but infra might add them back on (e.g., Netlify)
const pathname = window.location.pathname.replace(/\/+$/, '');
const mdUrl = `${pathname}.md`;
// Create fetch promise - in dev mode, return helpful message
@@ -101,7 +103,7 @@ export default function CopyMarkdownButton({ className, style }: CopyMarkdownBut
'inline-flex items-center justify-center'
)}
>
Copy as Markdown
Copy Markdown
</span>
<span
className={clsx(