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 () => {