diff --git a/apps/docs/components/GuidesSidebar.tsx b/apps/docs/components/GuidesSidebar.tsx
index ee4e8c49b4b..0fc561ff94f 100644
--- a/apps/docs/components/GuidesSidebar.tsx
+++ b/apps/docs/components/GuidesSidebar.tsx
@@ -19,16 +19,10 @@ interface TOCHeader {
function AiTools({ className }: { className?: string }) {
const [copied, setCopied] = useState(false)
- let url = ''
-
- // Safe check for server side rendering.
- try {
- const urlParts = new URL(`${window.location}`)
- url = urlParts.origin + urlParts.pathname
- } catch (error) {}
+ const path = usePathname()
async function copyMarkdown() {
- const mdUrl = `${url}.md`
+ const mdUrl = `/docs/${path}.md`
try {
const res = await fetch(mdUrl)
@@ -62,7 +56,7 @@ function AiTools({ className }: { className?: string }) {
{copied ? 'Copied!' : 'Copy as Markdown'}