Skip to content

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

feat: Add Guides layout support, schema, and sample page (#49930)

Jeremias Menichellicde5383e94b5
diff --git a/apps/kb/package.json b/apps/kb/package.json
index 109857da3d7..4e440f7e8bb 100644
--- a/apps/kb/package.json
+++ b/apps/kb/package.json
@@ -14,6 +14,7 @@
"dependencies": {
"@astrojs/react": "^6.0.4",
"astro": "^7.2.6",
+ "lucide-react": "*",
"react": "catalog:",
"react-dom": "catalog:",
"ui": "workspace:*"
diff --git a/apps/kb/src/components/Nav.tsx b/apps/kb/src/components/Nav.tsx
index 268a5953a1e..d28f765a059 100644
--- a/apps/kb/src/components/Nav.tsx
+++ b/apps/kb/src/components/Nav.tsx
@@ -30,7 +30,7 @@ const menus = [
]
const triggerClass =
- 'h-(--header-height) p-2 border-transparent font-normal rounded-none text-foreground-light hover:text-foreground data-open:text-foreground! border-0 focus-ring focus-visible:text-foreground h-full focus-visible:rounded-sm shadow-none!'
+ 'h-(--header-height) p-2 bg-transparent border-transparent font-normal rounded-none text-foreground-light hover:text-foreground data-open:text-foreground! border-0 focus-ring focus-visible:text-foreground h-full focus-visible:rounded-sm shadow-none!'
// docs gates this at `md:absolute` (its own base component class) because its
// nav is hidden entirely below `lg` in favor of a separate mobile menu. kb
// doesn't have that split — the nav is always visible — so `absolute` is
diff --git a/apps/kb/src/content.config.ts b/apps/kb/src/content.config.ts
new file mode 100644
index 00000000000..92612a16b79
--- /dev/null
+++ b/apps/kb/src/content.config.ts
@@ -0,0 +1,18 @@
+import { defineCollection } from 'astro:content'
+import { glob } from 'astro/loaders'
+import { z } from 'astro/zod'
+
+// Every entry here is rendered through GuideLayout by
+// src/pages/guides/[...slug].astro — dropping a new file in
+// src/content/guides doesn't need any per-file layout wiring.
+const guides = defineCollection({
+ loader: glob({ pattern: '**/*.md', base: './src/content/guides' }),
+ schema: z.object({
+ title: z.string(),
+ description: z.string().optional(),
+ topics: z.array(z.string()).optional(),
+ github_url: z.string().optional(),
+ }),
+})
+
+export const collections = { guides }
diff --git a/apps/kb/src/content/guides/sample-guide.md b/apps/kb/src/content/guides/sample-guide.md
new file mode 100644
index 00000000000..6a69b4987bc
--- /dev/null
+++ b/apps/kb/src/content/guides/sample-guide.md
@@ -0,0 +1,81 @@
+---
+title: 'Markdown elements sample'
+description: 'A lorem ipsum sample guide exercising every base Markdown element supported by the guide layout.'
+topics: ['example', 'markdown']
+github_url: 'https://github.com/supabase/supabase/discussions/0000000'
+---
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
+incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
+nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+
+## Heading level 2
+
+Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
+eu fugiat nulla pariatur. This paragraph mixes **bold text**, _italic text_,
+**_bold italic text_**, ~~strikethrough text~~, and `inline code`.
+
+### Heading level 3
+
+Here's a [link to the Astro docs](https://docs.astro.build/en/basics/layouts/),
+followed by an unordered list with a nested list:
+
+- Excepteur sint occaecat cupidatat non proident
+- Sunt in culpa qui officia deserunt mollit anim id est laborum
+ - Nested item one
+ - Nested item two
+- Curabitur blandit tempus porttitor
+
+#### Heading level 4
+
+And an ordered list with a nested list:
+
+1. Lorem ipsum dolor sit amet
+2. Consectetur adipiscing elit
+ 1. Nested step one
+ 2. Nested step two
+3. Sed do eiusmod tempor incididunt
+
+##### Heading level 5
+
+> Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
+> consectetur, adipisci velit.
+>
+> > Nested blockquote: at vero eos et accusamus et iusto odio dignissimos.
+
+###### Heading level 6
+
+A fenced code block with a language tag:
+
+```js
+function add(a, b) {
+ return a + b
+}
+
+console.log(add(2, 3))
+```
+
+And another in a different language:
+
+```bash
+npm install
+npm run dev
+```
+
+A table:
+
+| Element | Supported | Notes |
+| -------- | --------- | ---------------------------- |
+| Headings | Yes | h2 through h6 |
+| Tables | Yes | via GitHub-flavored Markdown |
+| Images | Yes | see below |
+
+An image:
+
+![Placeholder image](https://placehold.co/800x400?text=Placeholder+Image)
+
+---
+
+Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
+doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore
+veritatis et quasi architecto beatae vitae dicta sunt explicabo.
diff --git a/apps/kb/src/layouts/GuideLayout.astro b/apps/kb/src/layouts/GuideLayout.astro
new file mode 100644
index 00000000000..49b82d04b1c
--- /dev/null
+++ b/apps/kb/src/layouts/GuideLayout.astro
@@ -0,0 +1,39 @@
+---
+import { Github } from 'lucide-react'
+import { Badge } from 'ui'
+
+import Layout from './Layout.astro'
+
+interface Props {
+ title: string
+ description?: string
+ topics?: string[]
+ github_url?: string
+}
+
+const { title, description, topics = [], github_url } = Astro.props
+---
+
+<Layout title={title} description={description}>
+ <article class="prose max-w-3xl mx-auto px-6 py-16">
+ <h1>{title}</h1>
+ {description && <p class="lead">{description}</p>}
+ {
+ topics.length > 0 && (
+ <div class="flex flex-wrap gap-2">
+ {topics.map((topic) => <Badge>{topic}</Badge>)}
+ </div>
+ )
+ }
+ <slot />
+ {
+ github_url && (
+ <p>
+ <a href={github_url} target="_blank" rel="noreferrer" class="inline-flex items-center gap-1.5">
+ <Github size={16} /> Go to the GitHub discussion
+ </a>
+ </p>
+ )
+ }
+ </article>
+</Layout>
diff --git a/apps/kb/src/layouts/Layout.astro b/apps/kb/src/layouts/Layout.astro
index fc04f9e14e5..b49bd216520 100644
--- a/apps/kb/src/layouts/Layout.astro
+++ b/apps/kb/src/layouts/Layout.astro
@@ -1,6 +1,13 @@
---
import { Header } from '../components/Header'
import '../styles/globals.css'
+
+interface Props {
+ title: string
+ description?: string
+}
+
+const { title, description } = Astro.props
---
<!doctype html>
@@ -9,6 +16,7 @@ import '../styles/globals.css'
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta name="robots" content="noindex, nofollow" />
+ {description && <meta name="description" content={description} />}
<script is:inline>
// Set data-theme on <html> before first paint, so the page doesn't flash
// the wrong theme while this loads. Defaults to dark (no system-preference
@@ -50,7 +58,7 @@ import '../styles/globals.css'
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap"
/>
- <title>Supabase Knowledge Base</title>
+ <title>{title} | Supabase Knowledge Base</title>
</head>
<body>
<Header client:load />
diff --git a/apps/kb/src/pages/guides/[...slug].astro b/apps/kb/src/pages/guides/[...slug].astro
new file mode 100644
index 00000000000..d6b5c5de931
--- /dev/null
+++ b/apps/kb/src/pages/guides/[...slug].astro
@@ -0,0 +1,21 @@
+---
+import { getCollection, render } from 'astro:content'
+
+import GuideLayout from '../../layouts/GuideLayout.astro'
+
+export async function getStaticPaths() {
+ const guides = await getCollection('guides')
+ return guides.map((guide) => ({
+ params: { slug: guide.id },
+ props: { guide },
+ }))
+}
+
+const { guide } = Astro.props
+const { title, description, topics, github_url } = guide.data
+const { Content } = await render(guide)
+---
+
+<GuideLayout title={title} description={description} topics={topics} github_url={github_url}>
+ <Content />
+</GuideLayout>
diff --git a/apps/kb/src/pages/index.astro b/apps/kb/src/pages/index.astro
index d860bb804ea..fe909f38c65 100644
--- a/apps/kb/src/pages/index.astro
+++ b/apps/kb/src/pages/index.astro
@@ -3,6 +3,6 @@ import { Hero } from '../components/Hero'
import Layout from '../layouts/Layout.astro'
---
-<Layout>
+<Layout title="Home" description="In-depth guides, tutorials, and explainers for best practices for Supabase databases.">
<Hero />
</Layout>
diff --git a/apps/kb/src/styles/globals.css b/apps/kb/src/styles/globals.css
index bd5c11ac068..b15951345ec 100644
--- a/apps/kb/src/styles/globals.css
+++ b/apps/kb/src/styles/globals.css
@@ -72,3 +72,9 @@ h6:not(.font-mono),
::file-selector-button {
border-color: var(--border-default, currentColor);
}
+
+/* TEMPORARY UNTIL WE IMPLEMENT OUR OWN CODE COMPONENT */
+.prose pre code {
+ padding: 1rem;
+ display: inline-block;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ca4cb7e8981..359e330270c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -596,7 +596,7 @@ importers:
version: 7.29.7([email protected])
'@graphiql/toolkit':
specifier: ^0.9.1
'@graphql-codegen/cli':
specifier: 5.0.5
@@ -677,7 +677,7 @@ importers:
version: 13.2.2
graphiql:
specifier: ^4.0.2
npm-run-all:
specifier: ^4.1.5
version: 4.1.5
@@ -741,6 +741,9 @@ importers:
astro:
specifier: ^7.2.6
+ lucide-react:
+ specifier: '*'
+ version: 0.436.0([email protected])
react:
specifier: 'catalog:'
version: 19.2.6
@@ -14714,10 +14717,6 @@ packages:
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
engines: {node: '>=4'}
- resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==}
- engines: {node: '>=10'}
-
resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
engines: {node: '>=10'}
@@ -20685,9 +20684,9 @@ snapshots:
'@floating-ui/[email protected]': {}
dependencies:
graphql: 16.11.0
react: 19.2.6
@@ -20715,10 +20714,10 @@ snapshots:
- immer
- use-sync-external-store
dependencies:
react: 19.2.6
react-compiler-runtime: 19.1.0-rc.1([email protected])
react-dom: 19.2.6([email protected])
@@ -20747,9 +20746,9 @@ snapshots:
- immer
- use-sync-external-store
dependencies:
'@radix-ui/react-dropdown-menu': 2.1.16(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
@@ -20817,23 +20816,23 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
dependencies:
'@n1ru4l/push-pull-async-iterable-iterator': 3.2.0
graphql: 16.11.0
meros: 1.3.0(@types/[email protected])
optionalDependencies:
transitivePeerDependencies:
- '@types/node'
dependencies:
'@n1ru4l/push-pull-async-iterable-iterator': 3.2.0
graphql: 16.11.0
meros: 1.3.0(@types/[email protected])
optionalDependencies:
transitivePeerDependencies:
- '@types/node'
@@ -30306,11 +30305,11 @@ snapshots:
dependencies:
graphql: 16.11.0
react: 19.2.6
react-compiler-runtime: 19.1.0-rc.1([email protected])
@@ -30409,13 +30408,6 @@ snapshots:
optionalDependencies:
ws: 8.21.0
- dependencies:
- graphql: 16.11.0
- optionalDependencies:
- ws: 8.21.3
- optional: true
-
@@ -33086,8 +33078,6 @@ snapshots:
-
@@ -35996,7 +35986,7 @@ snapshots:
dependencies:
'@polka/url': 1.0.0-next.25
- mrmime: 2.0.0
+ mrmime: 2.0.1
totalist: 3.0.1