From efd45d7dc67cf8a8beabec797cdcbdad51e2902e Mon Sep 17 00:00:00 2001 From: Youssef Bentaleb Date: Thu, 25 Jan 2024 17:01:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20edit=20page=20link=20on?= =?UTF-8?q?=20wrapper=20broken=20404=20(#18700)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐞 fix: edit page link on wrapper broken 404 * Update apps/docs/layouts/guides/index.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Chris Gwilliams <517923+encima@users.noreply.github.com> Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --- apps/docs/layouts/DefaultGuideLayout.tsx | 1 + apps/docs/layouts/guides/index.tsx | 9 +++++++-- .../database/extensions/wrappers/[slug].tsx | 15 +++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/docs/layouts/DefaultGuideLayout.tsx b/apps/docs/layouts/DefaultGuideLayout.tsx index d2c01704763..71c1607f71a 100644 --- a/apps/docs/layouts/DefaultGuideLayout.tsx +++ b/apps/docs/layouts/DefaultGuideLayout.tsx @@ -13,6 +13,7 @@ interface Props { children: any toc?: any currentPage?: string + editLink?: string } const Layout: FC = (props) => { diff --git a/apps/docs/layouts/guides/index.tsx b/apps/docs/layouts/guides/index.tsx index fc0fc87ae40..c1677b2aa8b 100644 --- a/apps/docs/layouts/guides/index.tsx +++ b/apps/docs/layouts/guides/index.tsx @@ -23,6 +23,7 @@ interface Props { tocVideo?: string canonical?: string } + editLink?: string children: any toc?: any currentPage?: string @@ -136,8 +137,12 @@ const Layout: FC = (props) => {
Edit this page on GitHub diff --git a/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx b/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx index 2363a4ce7d0..64e70309bb7 100644 --- a/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx +++ b/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx @@ -80,11 +80,12 @@ interface WrappersDocsProps { title: string description?: string } + editLink?: string } -export default function WrappersDocs({ source, meta }: WrappersDocsProps) { +export default function WrappersDocs({ source, meta, editLink }: WrappersDocsProps) { return ( - + ) @@ -101,10 +102,9 @@ export const getStaticProps: GetStaticProps = async ({ params } const { remoteFile, meta } = page - - const response = await fetch( - `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}` - ) + const repoPath = `${org}/${repo}/${branch}/${docsDir}/${remoteFile}` + const repoEditPath = `${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}` + const response = await fetch(`https://raw.githubusercontent.com/${repoPath}`) const source = await response.text() @@ -119,7 +119,6 @@ export const getStaticProps: GetStaticProps = async ({ params if (hostname !== placeholderHostname || pathname === '/') { return url } - const relativePage = ( pathname.endsWith('.md') ? pathname.replace(/\.md$/, '') @@ -166,7 +165,7 @@ export const getStaticProps: GetStaticProps = async ({ params }, }) - return { props: { source: mdxSource, meta } } + return { props: { source: mdxSource, meta, editLink: repoEditPath } } } export const getStaticPaths: GetStaticPaths = async () => {