Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(kb) - add edit page on github links to bottom of KB guides (#51268)

Kody Jackson9e05961079c8
diff --git a/apps/kb/src/layouts/GuideLayout.astro b/apps/kb/src/layouts/GuideLayout.astro
index e29b15ae595..4cdee3914b3 100644
--- a/apps/kb/src/layouts/GuideLayout.astro
+++ b/apps/kb/src/layouts/GuideLayout.astro
@@ -1,5 +1,5 @@
---
-import { Github } from 'lucide-react'
+import { ExternalLink, Github } from 'lucide-react'
import { Badge } from 'ui'
import Layout from './Layout.astro'
@@ -10,10 +10,12 @@ interface Props {
description?: string
topics?: Topic[]
github_url?: string
+ viewGitHubLink?: string
date?: string
}
-const { title, description, topics = [], github_url, date } = Astro.props
+const { title, description, topics = [], github_url, viewGitHubLink, date } = Astro.props
+
---
<Layout title={title} description={description}>
@@ -45,5 +47,19 @@ const { title, description, topics = [], github_url, date } = Astro.props
</p>
)
}
+ {
+ viewGitHubLink && (
+ <footer class="mt-16 not-prose">
+ <a
+ href={viewGitHubLink}
+ target="_blank"
+ rel="noreferrer noopener edit"
+ class="w-fit inline-flex items-center gap-1 text-sm text-foreground-light hover:text-foreground"
+ >
+ View this page on GitHub <ExternalLink size={14} strokeWidth={1.5} />
+ </a>
+ </footer>
+ )
+ }
</article>
</Layout>
diff --git a/apps/kb/src/pages/guides/[...slug].astro b/apps/kb/src/pages/guides/[...slug].astro
index 1f57600c5a4..982f19576d8 100644
--- a/apps/kb/src/pages/guides/[...slug].astro
+++ b/apps/kb/src/pages/guides/[...slug].astro
@@ -15,8 +15,11 @@ export async function getStaticPaths() {
const { guide } = Astro.props
const { title, description, topics, github_url, date } = guide.data
const { Content } = await render(guide)
+
+// guide.filePath is relative to the kb app root, e.g. "src/content/guides/foo.mdx"
+const viewGitHubLink = `https://github.com/supabase/supabase/blob/master/apps/kb/${guide.filePath}`
---
-<GuideLayout title={title} description={description} topics={topics} github_url={github_url} date={date}>
+<GuideLayout title={title} description={description} topics={topics} github_url={github_url} viewGitHubLink={viewGitHubLink} date={date}>
<Content components={{ Admonition }} />
</GuideLayout>