The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(kb) - Add in structured FAQ generation + FAQ reference (#51795)
Kody Jackson2ea3566decd2
diff --git a/apps/kb/src/content.config.ts b/apps/kb/src/content.config.tsindex 77200347ce1..e1813c184c0 100644--- a/apps/kb/src/content.config.ts+++ b/apps/kb/src/content.config.ts@@ -73,4 +73,19 @@ const troubleshooting = defineCollection({}),})-export const collections = { guides, troubleshooting }+// Question-and-answer entries in src/content/faqs. `title` holds the question,+// and the body holds the answer. Entries are not rendered by a page yet — this+// collection only defines the schema so content can be authored against it.+const faqs = defineCollection({+ loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/faqs', generateId }),+ // Every entry is tagged with the FAQs topic in addition to any topics its+ // frontmatter lists, so it appears on /topics/faqs and its product topic pages.+ schema: z+ .object({+ title: z.string(),+ topics: z.array(z.string()).default([]),+ })+ .transform((data) => ({ ...data, topics: [...new Set(['FAQs', ...data.topics])] })),+})++export const collections = { guides, troubleshooting, faqs }diff --git a/apps/kb/src/content/faqs/auth/oidc-providers-supabase-project.mdx b/apps/kb/src/content/faqs/auth/oidc-providers-supabase-project.mdxnew file mode 100644index 00000000000..c8192096af6--- /dev/null+++ b/apps/kb/src/content/faqs/auth/oidc-providers-supabase-project.mdx@@ -0,0 +1,10 @@+---+title: Can I use OpenID Connect identity providers in Supabase projects?+topics: ['Auth']+---++Yes. Any identity provider that supports OpenID Connect (OIDC) can be used as a third-party authentication provider alongside Supabase Auth, or standalone, with your Supabase project.++For more details, refer to [Custom OIDC providers](https://supabase.com/docs/guides/auth/third-party/custom-oidc).++Supabase also provides first-class support for specific [third-party authentication providers](https://supabase.com/docs/guides/auth/third-party/overview).diff --git a/apps/kb/src/content/faqs/auth/oidc-providers-supported.mdx b/apps/kb/src/content/faqs/auth/oidc-providers-supported.mdxnew file mode 100644index 00000000000..f83cbb1e090--- /dev/null+++ b/apps/kb/src/content/faqs/auth/oidc-providers-supported.mdx@@ -0,0 +1,10 @@+---+title: Can I use a third-party authentication provider and Supabase Auth in the same project?+topics: ['Auth']+---++Yes. You can use a third-party authentication provider alongside [Supabase Auth](https://supabase.com/docs/guides/auth), or on its own. Supabase Auth stays enabled in every project, but your users do not need to sign in with it.++These third-party providers can then access Supabase features (like the [Data API (REST and GraphQL)](/docs/guides/database/overview), [Storage](/docs/guides/storage), [Realtime](/docs/guides/realtime) and [Edge functions](/docs/guides/functions)) from your existing apps.++For more details how this affects pricing, refer to [Manage Monthly Active Third-Party Users usage](https://supabase.com/docs/guides/platform/manage-your-usage/monthly-active-users-third-party).diff --git a/apps/kb/src/content/faqs/auth/supabase-auth-required-for-supabase.mdx b/apps/kb/src/content/faqs/auth/supabase-auth-required-for-supabase.mdxnew file mode 100644index 00000000000..55d3f6dde4d--- /dev/null+++ b/apps/kb/src/content/faqs/auth/supabase-auth-required-for-supabase.mdx@@ -0,0 +1,10 @@+---+title: Do I have to move my users to Supabase Auth to use Supabase?+topics: ['Auth']+---++No, you do not have to move your users to Supabase Auth to use Supabase.++If you want to use Supabase features (like the [Data API (REST and GraphQL)](/docs/guides/database/overview), [Storage](/docs/guides/storage), [Realtime](/docs/guides/realtime) and [Edge Functions](/docs/guides/functions)), Supabase provides first-class support for several [third-party authentication providers](https://supabase.com/docs/guides/auth/third-party/overview), so your existing users can stay where they are. These providers (Clerk, Firebase Auth, WorkOS, etc.) can then access Supabase features from your existing apps. For details about how this affects pricing, refer to [Manage Monthly Active Third-Party Users usage](https://supabase.com/docs/guides/platform/manage-your-usage/monthly-active-users-third-party).++You can also use Supabase as a standalone Postgres database, setting up your own authentication and authorization flows as needed.diff --git a/apps/kb/src/lib/cover-compositions.ts b/apps/kb/src/lib/cover-compositions.tsindex 8f432a35ccf..5d975cdbcac 100644--- a/apps/kb/src/lib/cover-compositions.ts+++ b/apps/kb/src/lib/cover-compositions.ts@@ -76,6 +76,13 @@ const PLATFORM_LAYERS: IsoBox[] = [0, 1, 2].map((i) => ({fillFace: 'top',}))+const FAQ_BLOCKS: IsoBox[] = [+ cube(0, 0, 0, 1),+ cube(1.4, 0, 0, 1),+ cube(0, 1.4, 0, 1),+ cube(1.4, 1.4, 0, 1),+]+export const ISO_COMPOSITIONS: Record<Topic, IsoComposition> = {Auth: {titleAt: 'bottom',@@ -159,6 +166,10 @@ export const ISO_COMPOSITIONS: Record<Topic, IsoComposition> = {nudgeY: 13,zoom: 0.645,},+ FAQs: {+ titleAt: 'top',+ boxes: FAQ_BLOCKS,+ },}export const FALLBACK_COMPOSITION: IsoComposition = { titleAt: 'top', boxes: [cube(0, 0, 0, 1)] }diff --git a/apps/kb/src/lib/guides.ts b/apps/kb/src/lib/guides.tsindex aaef63969c2..ab9918a185d 100644--- a/apps/kb/src/lib/guides.ts+++ b/apps/kb/src/lib/guides.ts@@ -54,6 +54,15 @@ export const toSummary = (guide: CollectionEntry<'guides'>): GuideSummary => ({date: guide.data.date,})+// FAQ entries have no description in frontmatter.+export const toFaqSummary = (faq: CollectionEntry<'faqs'>): GuideSummary => ({+ id: faq.id,+ title: faq.data.title,+ description: '',+ topics: faq.data.topics.filter((topic): topic is Topic => isKnownTopic(topic)),+ href: `${import.meta.env.BASE_URL}/faqs/${faq.id}`,+})+export const toTroubleshootingSummary = (entry: CollectionEntry<'troubleshooting'>): GuideSummary => ({diff --git a/apps/kb/src/lib/hero-shapes.ts b/apps/kb/src/lib/hero-shapes.tsindex c07d88b5f4b..7e8802e24f1 100644--- a/apps/kb/src/lib/hero-shapes.ts+++ b/apps/kb/src/lib/hero-shapes.ts@@ -3,6 +3,13 @@ import type { Topic } from './topics'const SHACKLE_LIFT = 2+const FAQ_BLOCKS: IsoBox[] = [+ cube(0, 0, 0, 1),+ cube(1.4, 0, 0, 1),+ cube(0, 1.4, 0, 1),+ cube(1.4, 1.4, 0, 1),+]+export const HERO_SHAPES: Record<Topic, IsoBox[]> = {Auth: [{ x: 0, y: 0, z: 0, w: 0.8, d: 1.8, h: 1.3, inset: 'front' },@@ -34,6 +41,7 @@ export const HERO_SHAPES: Record<Topic, IsoBox[]> = {],Tutorials: [0, 1, 2].map((i) => ({ ...cube(0, -i * 1.4, i * 0.85, 1.1), h: 0.6 })),Platform: [0, 1, 2].map((i) => ({ x: 0, y: 0, z: i * 0.9, w: 2.2, d: 2.2, h: 0.18 })),+ FAQs: FAQ_BLOCKS,}// a share of the shape's long side added on each edge, so a lone shape does not fill the flank.diff --git a/apps/kb/src/lib/topics.ts b/apps/kb/src/lib/topics.tsindex acfadb24c14..f9a40539451 100644--- a/apps/kb/src/lib/topics.ts+++ b/apps/kb/src/lib/topics.ts@@ -83,11 +83,17 @@ export const TOPICS = [pinned: false,visible: true,},+ {+ name: 'FAQs',+ description: 'Frequently asked questions and their answers.',+ pinned: false,+ visible: true,+ },] as constexport type Topic = (typeof TOPICS)[number]['name']-type ContentCollection = 'guides' | 'troubleshooting'+type ContentCollection = 'guides' | 'troubleshooting' | 'faqs'interface ListedTopicsParams {guides: { topics: readonly string[] }[]diff --git a/apps/kb/src/pages/faqs/[...slug].astro b/apps/kb/src/pages/faqs/[...slug].astronew file mode 100644index 00000000000..cf5e1c10e23--- /dev/null+++ b/apps/kb/src/pages/faqs/[...slug].astro@@ -0,0 +1,54 @@+---+import { getCollection, render } from 'astro:content'+import remarkParse from 'remark-parse'+import { Admonition } from 'ui-patterns/Admonition'+import { unified } from 'unified'+import { visit } from 'unist-util-visit'++import ArticleLayout from '../../layouts/ArticleLayout.astro'++export async function getStaticPaths() {+ const faqs = await getCollection('faqs')+ return faqs.map((faq) => ({+ params: { slug: faq.id },+ props: { faq },+ }))+}++const { faq } = Astro.props+const { title, topics } = faq.data+const { Content } = await render(faq)++// faq.filePath is relative to the kb app root, e.g. "src/content/faqs/auth/foo.mdx"+const viewGitHubLink = `https://github.com/supabase/supabase/blob/master/apps/kb/${faq.filePath}`++// Plain text of the answer's paragraphs and headings, for the schema below.+const blocks: string[] = []+visit(unified().use(remarkParse).parse(faq.body ?? ''), (node) => {+ if (node.type !== 'paragraph' && node.type !== 'heading') return+ let text = ''+ visit(node, (child) => {+ if (child.type === 'text' || child.type === 'inlineCode') text += child.value+ })+ if (text) blocks.push(text)+})++// https://schema.org/FAQPage for this page's single question. "<" is escaped so+// the JSON can't close the script tag early.+const faqPageJsonLd = JSON.stringify({+ '@context': 'https://schema.org',+ '@type': 'FAQPage',+ mainEntity: [+ {+ '@type': 'Question',+ name: title,+ acceptedAnswer: { '@type': 'Answer', text: blocks.join('\n\n') },+ },+ ],+}).replace(/</g, '\\u003c')+---++<ArticleLayout title={title} topics={topics} viewGitHubLink={viewGitHubLink}>+ <script type="application/ld+json" set:html={faqPageJsonLd} />+ <Content components={{ Admonition }} />+</ArticleLayout>diff --git a/apps/kb/src/pages/topics/[topic].astro b/apps/kb/src/pages/topics/[topic].astroindex bdfb77c6440..c0bedbea2c9 100644--- a/apps/kb/src/pages/topics/[topic].astro+++ b/apps/kb/src/pages/topics/[topic].astro@@ -5,13 +5,14 @@ import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList } from 'ui'import { GuideBrowser } from '../../components/GuideBrowser'import { TopicHero } from '../../components/Hero'import Layout from '../../layouts/Layout.astro'-import { toSummary, toTroubleshootingSummary } from '../../lib/guides'+import { toFaqSummary, toSummary, toTroubleshootingSummary } from '../../lib/guides'import { breadcrumbListSchema, canonicalUrl, KB_BASE_URL } from '../../lib/json-ld'import { isInTopic, TOPICS, topicToSlug } from '../../lib/topics'export async function getStaticPaths() {const guides = (await getCollection('guides')).map(toSummary)const troubleshooting = (await getCollection('troubleshooting')).map(toTroubleshootingSummary)+ const faqs = (await getCollection('faqs')).map(toFaqSummary)// One page per topic in TOPICS — not just topics a guide already uses —// so every link on the "Topics" nav resolves instead of 404ing.@@ -26,11 +27,14 @@ export async function getStaticPaths() {troubleshooting: troubleshooting.filter((entry) =>isInTopic({ collection: 'troubleshooting', topics: entry.topics, topic: topic.name })),+ faqs: faqs.filter((entry) =>+ isInTopic({ collection: 'faqs', topics: entry.topics, topic: topic.name })+ ),},}))}-const { topic, description, guides, troubleshooting } = Astro.props+const { topic, description, guides, troubleshooting, faqs } = Astro.propsconst url = canonicalUrl(Astro.url.pathname)const jsonLd = breadcrumbListSchema([{ name: 'Knowledge Base', url: KB_BASE_URL },@@ -39,7 +43,7 @@ const jsonLd = breadcrumbListSchema([---<Layout title={topic} description={description} jsonLd={jsonLd}>- <TopicHero client:load topic={topic} description={description} guides={[...guides, ...troubleshooting]}>+ <TopicHero client:load topic={topic} description={description} guides={[...guides, ...troubleshooting, ...faqs]}><Breadcrumb slot="breadcrumb"><BreadcrumbList><BreadcrumbItem>@@ -50,7 +54,7 @@ const jsonLd = breadcrumbListSchema([</TopicHero><div class="flex flex-col gap-20 pb-24 pt-16 sm:gap-24 sm:pt-20">{- guides.length === 0 && troubleshooting.length === 0 ? (+ guides.length === 0 && troubleshooting.length === 0 && faqs.length === 0 ? (<p class="mx-auto max-w-6xl px-6 text-sm text-foreground-light">No guides for this topic yet.</p>) : null}@@ -60,5 +64,10 @@ const jsonLd = breadcrumbListSchema([<GuideBrowser client:load title="Troubleshooting" guides={troubleshooting} param="troubleshooting" />) : null}+ {+ faqs.length > 0 ? (+ <GuideBrowser client:load title="FAQs" guides={faqs} param="faqs" />+ ) : null+ }</div></Layout>diff --git a/apps/kb/vercel.json b/apps/kb/vercel.jsonindex 8af8b810171..3d3f30f3d02 100644--- a/apps/kb/vercel.json+++ b/apps/kb/vercel.json@@ -18,6 +18,11 @@"source": "/kb/troubleshooting/:path+.md","destination": "/kb/markdown/troubleshooting/:path+.md","permanent": true+ },+ {+ "source": "/kb/faqs/:path+.md",+ "destination": "/kb/markdown/faqs/:path+.md",+ "permanent": true}],"rewrites": [@@ -36,6 +41,11 @@"has": [{ "type": "header", "key": "accept", "value": "(?i).*text/markdown.*" }],"destination": "/markdown/troubleshooting/:path+.md"},+ {+ "source": "/kb/faqs/:path+",+ "has": [{ "type": "header", "key": "accept", "value": "(?i).*text/markdown.*" }],+ "destination": "/markdown/faqs/:path+.md"+ },{ "source": "/kb", "destination": "/index.html" },{ "source": "/kb/:path*", "destination": "/:path*" }],@@ -51,6 +61,10 @@{"source": "/kb/troubleshooting/:path+","headers": [{ "key": "Vary", "value": "Accept" }]+ },+ {+ "source": "/kb/faqs/:path+",+ "headers": [{ "key": "Vary", "value": "Accept" }]}]}