The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
[DOCS-979] feat(Docs): Generate new markdown files for reference pages (#46727)
Jeremias Menichelli575ac8c64595
diff --git a/apps/docs/.gitignore b/apps/docs/.gitignoreindex af74dd45e2a..eb1e923d280 100644--- a/apps/docs/.gitignore+++ b/apps/docs/.gitignore@@ -29,8 +29,8 @@ yarn-error.log*public/sitemap.xml# Per-source llms files (generated by build:llms, served by www)public/llms/-# Generated guide markdown files-public/docs/+# Generated guide and reference markdown files+public/markdown/public/docs.tar.gz# Copied examples folderdiff --git a/apps/docs/DEVELOPERS.md b/apps/docs/DEVELOPERS.mdindex 1f0c0d0b8a9..ea96686cb08 100644--- a/apps/docs/DEVELOPERS.md+++ b/apps/docs/DEVELOPERS.md@@ -31,7 +31,7 @@ To test locally, within the `apps/docs` directory:1. Run `pnpm build:guides-markdown`2. Run `pnpm dev`-This creates Markdown files for all routes under the `public/docs/guides` directory, ignored by Git.+This creates Markdown files for all routes under the `public/markdown/guides` directory, ignored by Git.For production this setup runs as a `prebuild` task to allow Vercel to bundle these files with middleware and functions.diff --git a/apps/docs/app/api/guides-md/[...slug]/route.ts b/apps/docs/app/api/guides-md/[...slug]/route.tsindex 3e877b3181f..51dea28525c 100644--- a/apps/docs/app/api/guides-md/[...slug]/route.ts+++ b/apps/docs/app/api/guides-md/[...slug]/route.ts@@ -5,7 +5,7 @@ import { NextResponse } from 'next/server'export async function GET(request: Request, { params }: { params: Promise<{ slug: string[] }> }) {const { slug } = await params- const baseDir = path.join(process.cwd(), 'public/docs/guides')+ const baseDir = path.join(process.cwd(), 'public/markdown/guides')const filePath = path.join(baseDir, `${slug.join('/')}.md`)if (!filePath.startsWith(baseDir + path.sep) && filePath !== baseDir) {diff --git a/apps/docs/internals/generate-guides-markdown.ts b/apps/docs/internals/generate-guides-markdown.tsindex 0e283f27aaa..8fdf3273617 100644--- a/apps/docs/internals/generate-guides-markdown.ts+++ b/apps/docs/internals/generate-guides-markdown.ts@@ -200,7 +200,7 @@ async function generate() {await Promise.all(files.map(async (filePath) => {const outPath = filePath- .replace(/^content\/guides\//, 'public/docs/guides/')+ .replace(/^content\/guides\//, 'public/markdown/guides/').replace(/\.mdx$/, '.md')let output: string@@ -234,8 +234,8 @@ async function generate() {}}- // content/guides/ai/vector-columns.mdx → public/docs/guides/ai/vector-columns.md- // Placing under public/docs/ ensures the file is served at /docs/guides/...+ // content/guides/ai/vector-columns.mdx → public/markdown/guides/ai/vector-columns.md+ // Placing under public/markdown/ ensures the file is served at /docs/guides/...// matching the exact URL of the rendered page.await fs.promises.mkdir(path.dirname(outPath), { recursive: true })await fs.promises.writeFile(outPath, output)@@ -243,7 +243,7 @@ async function generate() {)const summary = warnings ? ` (${warnings} with warnings)` : ''- console.log(`Generated ${files.length} markdown files under public/docs/guides/${summary}`)+ console.log(`Generated ${files.length} markdown files under public/markdown/guides/${summary}`)}generate()diff --git a/apps/docs/internals/generate-gz-archive.ts b/apps/docs/internals/generate-gz-archive.tsindex 4e57d219ccd..491f85441f1 100644--- a/apps/docs/internals/generate-gz-archive.ts+++ b/apps/docs/internals/generate-gz-archive.ts@@ -5,9 +5,9 @@ async function generate() {// Create a tar.gz archive of the generated docs, served at /docs/docs.tar.gz.// Sorted entries, portable headers, and a fixed mtime keep the output deterministic.const archivePath = 'public/docs.tar.gz'- const entries = (await globby(['**'], { cwd: 'public/docs' })).sort()+ const entries = (await globby(['**'], { cwd: 'public/markdown' })).sort()await createTar(- { gzip: true, file: archivePath, cwd: 'public/docs', portable: true, mtime: new Date() },+ { gzip: true, file: archivePath, cwd: 'public/markdown', portable: true, mtime: new Date() },entries)console.log(`Created archive at ${archivePath}`)diff --git a/apps/docs/internals/generate-reference-markdown.ts b/apps/docs/internals/generate-reference-markdown.tsnew file mode 100644index 00000000000..f216ff89e52--- /dev/null+++ b/apps/docs/internals/generate-reference-markdown.ts@@ -0,0 +1,414 @@+import fs from 'node:fs/promises'+import path from 'node:path'+import matter from 'gray-matter'+import yaml from 'js-yaml'++const GENERATED = path.join(process.cwd(), 'features/docs/generated')+const OUT_DIR = path.join(process.cwd(), 'public/markdown/reference')+const MDX_ROOT = path.join(process.cwd(), 'docs/ref')++type Section = {+ id?: string+ title?: string+ slug?: string+ type?: string+ items?: Section[]+}++type Example = { name?: string; code?: string }++type LegacyFn = {+ id: string+ $ref?: string+ title?: string+ description?: string+ notes?: string+ examples?: Example[]+}++type TypeSpec = {+ methods: Record<string, { comment?: { shortText?: string; examples?: Example[] } }>+}++type RefBase = {+ title: string+ outFile: string+ /** Folder under docs/ref/ that holds .mdx sections for `type: "markdown"` entries. */+ mdxDir: string+}++type SdkLegacyRef = RefBase & {+ kind: 'sdk-legacy'+ sectionsPath: string+ functionsPath: string+}++type SdkNewRef = RefBase & {+ kind: 'sdk-new'+ contentDir: string+}++type ApiRef = RefBase & {+ kind: 'api'+ sectionsPath: string+ endpointsByIdPath: string+}++type CliRef = RefBase & {+ kind: 'cli'+ sectionsPath: string+ cliSpecPath: string+}++type Ref = SdkLegacyRef | SdkNewRef | ApiRef | CliRef++const REFERENCES: Ref[] = [+ {+ kind: 'api',+ title: 'Management API Reference',+ outFile: 'api.md',+ mdxDir: path.join(MDX_ROOT, 'api'),+ sectionsPath: path.join(GENERATED, 'api.latest.sections.json'),+ endpointsByIdPath: path.join(GENERATED, 'api.latest.endpointsById.json'),+ },+ {+ kind: 'cli',+ title: 'Supabase CLI Reference',+ outFile: 'cli.md',+ mdxDir: path.join(MDX_ROOT, 'cli'),+ sectionsPath: path.join(GENERATED, 'cli.latest.sections.json'),+ cliSpecPath: path.join(process.cwd(), 'spec/cli_v1_commands.yaml'),+ },+ {+ kind: 'sdk-new',+ title: 'JavaScript Client Library Reference',+ outFile: 'js.md',+ mdxDir: path.join(MDX_ROOT, 'javascript'),+ contentDir: path.join(process.cwd(), 'content/reference/javascript/v2'),+ },+ {+ kind: 'sdk-legacy',+ title: 'Dart Client Library Reference',+ outFile: 'dart.md',+ mdxDir: path.join(MDX_ROOT, 'dart'),+ sectionsPath: path.join(GENERATED, 'dart.v2.sections.json'),+ functionsPath: path.join(GENERATED, 'dart.v2.functions.json'),+ },+ {+ kind: 'sdk-legacy',+ title: 'Kotlin Client Library Reference',+ outFile: 'kotlin.md',+ mdxDir: path.join(MDX_ROOT, 'kotlin'),+ sectionsPath: path.join(GENERATED, 'kotlin.v1.sections.json'),+ functionsPath: path.join(GENERATED, 'kotlin.v1.functions.json'),+ },+ {+ kind: 'sdk-legacy',+ title: 'Python Client Library Reference',+ outFile: 'python.md',+ mdxDir: path.join(MDX_ROOT, 'python'),+ sectionsPath: path.join(GENERATED, 'python.v2.sections.json'),+ functionsPath: path.join(GENERATED, 'python.v2.functions.json'),+ },+ {+ kind: 'sdk-legacy',+ title: 'Swift Client Library Reference',+ outFile: 'swift.md',+ mdxDir: path.join(MDX_ROOT, 'swift'),+ sectionsPath: path.join(GENERATED, 'swift.v2.sections.json'),+ functionsPath: path.join(GENERATED, 'swift.v2.functions.json'),+ },+ {+ kind: 'sdk-legacy',+ title: 'C# Client Library Reference',+ outFile: 'csharp.md',+ mdxDir: path.join(MDX_ROOT, 'csharp'),+ sectionsPath: path.join(GENERATED, 'csharp.v0.sections.json'),+ functionsPath: path.join(GENERATED, 'csharp.v0.functions.json'),+ },+]++function flatten(sections: Section[]): Section[] {+ return sections.flatMap((s) => (s.items ? [s, ...flatten(s.items)] : [s]))+}++async function readJson<T>(filePath: string): Promise<T> {+ return JSON.parse(await fs.readFile(filePath, 'utf8')) as T+}++function renderExamples(examples: Example[] | undefined): string {+ if (!examples?.length) return ''+ const blocks = examples+ .map((ex) => {+ const header = ex.name ? `#### ${ex.name}\n\n` : ''+ const code = (ex.code ?? '').trim()+ return code ? `${header}${code}` : header.trim()+ })+ .filter(Boolean)+ return blocks.length ? `### Examples\n\n${blocks.join('\n\n')}` : ''+}++function renderFunctionSection(args: {+ title: string+ description?: string+ notes?: string+ examples?: Example[]+}): string {+ const parts = [`## ${args.title}`]+ if (args.description?.trim()) parts.push(args.description.trim())+ if (args.notes?.trim()) parts.push(args.notes.trim())+ const examples = renderExamples(args.examples)+ if (examples) parts.push(examples)+ return parts.join('\n\n')+}++/** Remove the minimum common leading whitespace from all non-empty lines. */+function dedentBlock(text: string): string {+ const lines = text.split('\n')+ const nonEmpty = lines.filter((l) => /\S/.test(l))+ if (!nonEmpty.length) return text+ const minIndent = Math.min(...nonEmpty.map((l) => (l.match(/^([ \t]*)/) ?? ['', ''])[1].length))+ if (!minIndent) return text+ return lines.map((l) => l.slice(minIndent)).join('\n')+}++/**+ * Strip MDX comments and JSX component tags while keeping inner prose/code.+ * Outside code fences, leading whitespace from JSX nesting is removed. Inside+ * code fences, the body is dedented so the closing fence sits flush left.+ */+function stripMdxJsx(content: string): string {+ const segments = content.split(/(```[\s\S]*?```)/g)+ return segments+ .map((seg, i) => {+ if (i % 2 === 0) {+ let prose = seg+ prose = prose.replace(/\{\/\*[\s\S]*?\*\/\}/g, '')+ prose = prose.replace(/<[$A-Z][\w.]*(?:\s[^>]*)?\s*\/>/gs, '')+ prose = prose.replace(/<[$A-Z][\w.]*(?:\s[^>]*)?\s*>/gs, '')+ prose = prose.replace(/<\/[$A-Z][\w.]*>/g, '')+ prose = prose.replace(/<\/?(?:div|a|span|p|h[1-6])(?:\s[^>]*)?\s*>/g, '')+ return prose.replace(/^[ \t]+/gm, '')+ }+ return seg.replace(+ /^(```[^\n]*\n)([\s\S]*?)(\n[ \t]*```)$/,+ (_, open, body) => open + dedentBlock(body) + '\n```'+ )+ })+ .join('')+ .replace(/^[^\S\n]+$/gm, '')+ .replace(/\n{3,}/g, '\n\n')+ .trim()+}++/**+ * Read a `type: "markdown"` section's .mdx file and convert it to plain+ * markdown. Returns null if the file doesn't exist or has no usable content.+ */+async function renderMarkdownSection(mdxDir: string, section: Section): Promise<string | null> {+ if (!section.slug) return null+ let raw: string+ try {+ raw = await fs.readFile(path.join(mdxDir, `${section.slug}.mdx`), 'utf8')+ } catch {+ return null+ }+ const { content, data } = matter(raw)+ const body = stripMdxJsx(content)+ if (!body) return null+ const heading = data.hideTitle+ ? null+ : ((typeof data.title === 'string' ? data.title : section.title) ?? null)+ return heading ? `## ${heading}\n\n${body}` : body+}++async function renderSdkLegacy(ref: SdkLegacyRef, sharedTypeSpec: TypeSpec): Promise<string> {+ const [sections, functions] = await Promise.all([+ readJson<Section[]>(ref.sectionsPath),+ readJson<LegacyFn[]>(ref.functionsPath),+ ])+ const fnsById = new Map(functions.map((fn) => [fn.id, fn]))+ const methodsByRef = new Map(Object.entries(sharedTypeSpec.methods ?? {}))++ const parts: string[] = [`# ${ref.title}`]+ for (const section of flatten(sections)) {+ if (section.type === 'category' && section.title) {+ parts.push(`## ${section.title}`)+ continue+ }+ if (section.type === 'markdown') {+ const md = await renderMarkdownSection(ref.mdxDir, section)+ if (md) parts.push(md)+ continue+ }+ if (section.type !== 'function' || !section.id) continue+ const fn = fnsById.get(section.id)+ if (!fn) continue+ const tsm = fn.$ref ? methodsByRef.get(fn.$ref) : undefined+ parts.push(+ renderFunctionSection({+ title: fn.title || section.title || fn.id,+ description: fn.description ?? tsm?.comment?.shortText,+ notes: fn.notes,+ examples: fn.examples ?? tsm?.comment?.examples,+ })+ )+ }+ return parts.join('\n\n') + '\n'+}++async function renderSdkNew(ref: SdkNewRef): Promise<string> {+ const [sections, functions, typeSpec] = await Promise.all([+ readJson<Section[]>(path.join(ref.contentDir, 'sections.json')),+ readJson<LegacyFn[]>(path.join(ref.contentDir, 'functions.json')),+ readJson<TypeSpec>(path.join(ref.contentDir, 'typeSpec.json')),+ ])+ const fnsById = new Map(functions.map((fn) => [fn.id, fn]))+ const methods = typeSpec.methods ?? {}++ const parts: string[] = [`# ${ref.title}`]+ for (const section of flatten(sections)) {+ if (section.type === 'category' && section.title) {+ parts.push(`## ${section.title}`)+ continue+ }+ if (section.type === 'markdown') {+ const md = await renderMarkdownSection(ref.mdxDir, section)+ if (md) parts.push(md)+ continue+ }+ if (section.type !== 'function' || !section.id) continue+ const fn = fnsById.get(section.id)+ if (!fn) continue+ const tsm = fn.$ref ? methods[fn.$ref] : undefined+ parts.push(+ renderFunctionSection({+ title: fn.title || section.title || fn.id,+ description: fn.description ?? tsm?.comment?.shortText,+ notes: fn.notes,+ examples: fn.examples ?? tsm?.comment?.examples,+ })+ )+ }+ return parts.join('\n\n') + '\n'+}++async function renderApi(ref: ApiRef): Promise<string> {+ type Endpoint = {+ summary?: string+ description?: string+ path?: string+ method?: string+ parameters?: Array<{+ name: string+ required?: boolean+ description?: string+ schema?: { type?: string }+ }>+ }+ const [sections, entries] = await Promise.all([+ readJson<Section[]>(ref.sectionsPath),+ readJson<Array<[string, Endpoint]>>(ref.endpointsByIdPath),+ ])+ const endpointsById = new Map(entries)++ const parts: string[] = [`# ${ref.title}`]+ for (const section of flatten(sections)) {+ if (section.type === 'category' && section.title) {+ parts.push(`## ${section.title}`)+ continue+ }+ if (section.type === 'markdown') {+ const md = await renderMarkdownSection(ref.mdxDir, section)+ if (md) parts.push(md)+ continue+ }+ if (section.type !== 'operation' || !section.id) continue+ const ep = endpointsById.get(section.id)+ if (!ep) continue+ const heading = ep.summary || section.title || section.id+ const block = [`## ${heading}`]+ if (ep.path) block.push(`\`${(ep.method ?? 'GET').toUpperCase()} ${ep.path}\``)+ if (ep.description?.trim()) block.push(ep.description.trim())+ if (ep.parameters?.length) {+ const list = ep.parameters+ .map((p) => {+ const required = p.required ? 'required' : 'optional'+ const type = p.schema?.type ?? 'string'+ return `- \`${p.name}\` (${type}, ${required})${p.description ? `: ${p.description}` : ''}`+ })+ .join('\n')+ block.push(`### Parameters\n\n${list}`)+ }+ parts.push(block.join('\n\n'))+ }+ return parts.join('\n\n') + '\n'+}++async function renderCli(ref: CliRef): Promise<string> {+ type Command = {+ id: string+ title?: string+ summary?: string+ description?: string+ usage?: string+ }+ const [sections, spec] = await Promise.all([+ readJson<Section[]>(ref.sectionsPath),+ fs.readFile(ref.cliSpecPath, 'utf8').then((raw) => yaml.load(raw) as { commands: Command[] }),+ ])+ const cmdsById = new Map((spec.commands ?? []).map((c) => [c.id, c]))++ const parts: string[] = [`# ${ref.title}`]+ for (const section of flatten(sections)) {+ if (section.type === 'category' && section.title) {+ parts.push(`## ${section.title}`)+ continue+ }+ if (section.type === 'markdown') {+ const md = await renderMarkdownSection(ref.mdxDir, section)+ if (md) parts.push(md)+ continue+ }+ if (section.type !== 'cli-command' || !section.id) continue+ const cmd = cmdsById.get(section.id)+ if (!cmd) continue+ const block = [`## ${cmd.summary || cmd.title || section.title || section.id}`]+ if (cmd.description?.trim()) block.push(cmd.description.trim())+ if (cmd.usage?.trim()) block.push('```sh\n' + cmd.usage.trim() + '\n```')+ parts.push(block.join('\n\n'))+ }+ return parts.join('\n\n') + '\n'+}++async function generate() {+ await fs.mkdir(OUT_DIR, { recursive: true })+ const sharedTypeSpec = await readJson<TypeSpec>(+ path.join(process.cwd(), 'content/reference/javascript/v2/typeSpec.json')+ )++ await Promise.all(+ REFERENCES.map(async (ref) => {+ let output: string+ switch (ref.kind) {+ case 'sdk-legacy':+ output = await renderSdkLegacy(ref, sharedTypeSpec)+ break+ case 'sdk-new':+ output = await renderSdkNew(ref)+ break+ case 'api':+ output = await renderApi(ref)+ break+ case 'cli':+ output = await renderCli(ref)+ break+ }+ await fs.writeFile(path.join(OUT_DIR, ref.outFile), output)+ })+ )++ console.log(`Generated ${REFERENCES.length} markdown files under public/markdown/reference/`)+}++generate()diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjsindex 9243af773b2..8fa45e13c6d 100644--- a/apps/docs/next.config.mjs+++ b/apps/docs/next.config.mjs@@ -61,7 +61,7 @@ const nextConfig = {],outputFileTracingIncludes: {'/api/crawlers': ['./features/docs/generated/**/*', './docs/ref/**/*'],- '/api/guides-md/**/*': ['./public/docs/guides/**/*'],+ '/api/guides-md/**/*': ['./public/markdown/guides/**/*'],'/guides/**/*': ['./content/guides/**/*', './content/troubleshooting/**/*', './examples/**/*'],'/reference/**/*': ['./features/docs/generated/**/*', './docs/ref/**/*'],},diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex baef799f723..bf086e3a985 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -6,16 +6,19 @@"scripts": {"build": "next build","build:analyze": "ANALYZE=true next build",- "build:llms": "tsx --conditions=react-server ./scripts/llms.ts","build:guides-markdown": "tsx ./internals/generate-guides-markdown.ts",+ "prebuild:reference-markdown": "pnpm run codegen:references",+ "build:reference-markdown": "tsx ./internals/generate-reference-markdown.ts",+ "build:markdown": "pnpm build:guides-markdown && pnpm build:reference-markdown","build:gz-archive": "tsx ./internals/generate-gz-archive.ts","build:sitemap": "tsx ./internals/generate-sitemap.ts","clean": "rimraf .next .turbo node_modules features/docs/generated examples __generated__","codegen:examples": "shx cp -r ../../examples ./examples","codegen:graphql": "tsx --conditions=react-server ./scripts/graphqlSchema.ts && graphql-codegen --config codegen.ts",- "codegen:references:ensure": "test -f spec/reference/javascript/v2/supabase.json || (cd spec && make download.tsdoc.v2)",- "codegen:references:new": "pnpm run codegen:references:ensure && tsx scripts/build-reference-content.ts",- "codegen:references": "tsx features/docs/Reference.generated.script.ts",+ "codegen:references:new:ensure": "test -f spec/reference/javascript/v2/supabase.json || (cd spec && make download.tsdoc.v2)",+ "codegen:references:new": "pnpm run codegen:references:new:ensure && tsx scripts/build-reference-content.ts",+ "codegen:references:legacy": "tsx features/docs/Reference.generated.script.ts",+ "codegen:references": "pnpm codegen:references:legacy && pnpm codegen:references:new","codemod:frontmatter": "node ./scripts/codemod/mdx-meta.mjs && prettier --cache --write \"content/**/*.mdx\"","dev": "concurrently --kill-others \"next dev --port 3001\" \"pnpm run dev:watch:troubleshooting\"","dev:secrets:pull": "AWS_PROFILE=supa-dev node ../../scripts/getSecrets.js -n local/docs",@@ -28,10 +31,10 @@"last-changed:reset": "pnpm run last-changed -- --reset","lint": "eslint .","lint:mdx": "supa-mdx-lint content --config ../../supa-mdx-lint.config.toml",- "postbuild": "pnpm run build:sitemap && pnpm run build:llms && ./../../scripts/upload-static-assets.sh",- "prebuild": "pnpm run codegen:graphql && pnpm run codegen:references && pnpm run codegen:references:new && pnpm run codegen:examples && pnpm run build:guides-markdown && pnpm run build:gz-archive",- "predev": "pnpm run codegen:graphql && pnpm run codegen:references && pnpm run codegen:references:new && pnpm run codegen:examples",- "preembeddings": "pnpm run codegen:references && pnpm run codegen:references:new",+ "postbuild": "pnpm run build:sitemap && ./../../scripts/upload-static-assets.sh",+ "prebuild": "pnpm run codegen:graphql && pnpm run codegen:references && pnpm run codegen:examples && pnpm run build:markdown && pnpm run build:gz-archive",+ "predev": "pnpm run codegen:graphql && pnpm run codegen:references && pnpm run codegen:examples",+ "preembeddings": "pnpm run codegen:references","preinstall": "npx only-allow pnpm","presync": "pnpm run codegen:graphql","pretest": "pnpm run codegen:examples",diff --git a/apps/docs/scripts/llms.ts b/apps/docs/scripts/llms.tsdeleted file mode 100644index 441638c01e9..00000000000--- a/apps/docs/scripts/llms.ts+++ /dev/null@@ -1,144 +0,0 @@-import './utils/dotenv.js'-import 'dotenv/config'--import fs from 'node:fs/promises'-import { fileURLToPath } from 'node:url'--import { isFeatureEnabled } from '../../../packages/common/enabled-features/index.js'-import {- fetchCliLibReferenceSource,- fetchCSharpLibReferenceSource,- fetchDartLibReferenceSource,- fetchGuideSources,- fetchJsLibReferenceSource,- fetchKtLibReferenceSource,- fetchPythonLibReferenceSource,- fetchSwiftLibReferenceSource,- type SearchSource,-} from './search/sources/index.js'--interface Source {- title: string- /**- * Path relative to https://supabase.com. No leading slash- */- relPath: string- fetch: () => Promise<SearchSource[]>- enabled: boolean-}--const {- sdkCsharp: sdkCsharpEnabled,- sdkDart: sdkDartEnabled,- sdkKotlin: sdkKotlinEnabled,- sdkPython: sdkPythonEnabled,- sdkSwift: sdkSwiftEnabled,-} = isFeatureEnabled(['sdk:csharp', 'sdk:dart', 'sdk:kotlin', 'sdk:python', 'sdk:swift'])--const SOURCES: Source[] = [- {- title: 'Supabase Guides',- relPath: 'llms/guides.txt',- fetch: fetchGuideSources,- enabled: true,- },- {- title: 'Supabase Reference (JavaScript)',- relPath: 'llms/js.txt',- fetch: async () =>- (await fetchJsLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: true,- },- {- title: 'Supabase Reference (Dart)',- relPath: 'llms/dart.txt',- fetch: async () =>- (await fetchDartLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: sdkDartEnabled,- },- {- title: 'Supabase Reference (Swift)',- relPath: 'llms/swift.txt',- fetch: async () =>- (await fetchSwiftLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: sdkSwiftEnabled,- },- {- title: 'Supabase Reference (Kotlin)',- relPath: 'llms/kotlin.txt',- fetch: async () =>- (await fetchKtLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: sdkKotlinEnabled,- },- {- title: 'Supabase Reference (Python)',- relPath: 'llms/python.txt',- fetch: async () =>- (await fetchPythonLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: sdkPythonEnabled,- },- {- title: 'Supabase Reference (C#)',- relPath: 'llms/csharp.txt',- fetch: async () =>- (await fetchCSharpLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: sdkCsharpEnabled,- },- {- title: 'Supabase CLI Reference',- relPath: 'llms/cli.txt',- fetch: async () =>- (await fetchCliLibReferenceSource()).filter(- (item): item is SearchSource => item !== undefined- ),- enabled: true,- },-]--async function generateLlmsTxt() {- try {- await fs.mkdir('public/llms', { recursive: true })-- const enabledSources = SOURCES.filter((source) => source.enabled !== false)-- const fetchedSources = await Promise.all(- enabledSources.map(async (sourceDefn) => {- const source = await sourceDefn.fetch()- const sourceText = source- .map((section) => {- section.process()- return section.extractIndexedContent()- })- .join('\n\n')- return { defn: sourceDefn, text: sourceText }- })- )-- await Promise.all(- fetchedSources.map(({ defn, text }) =>- fs.writeFile(`public/${defn.relPath}`, `${defn.title}\n\n${text}`)- )- )- } catch (err) {- console.error(err)- throw err- }-}--if (process.argv[1] === fileURLToPath(import.meta.url)) {- generateLlmsTxt()-}--export { generateLlmsTxt, SOURCES }diff --git a/apps/www/app/llms-full.txt/route.ts b/apps/www/app/llms-full.txt/route.tsindex ca14a785f0d..d09119bdc14 100644--- a/apps/www/app/llms-full.txt/route.ts+++ b/apps/www/app/llms-full.txt/route.ts@@ -18,7 +18,7 @@ interface Source {* included in the serverless bundle via outputFileTracingIncludes in* next.config.mjs so reads work on Vercel.*/-const GUIDES_MD_DIR = path.join(process.cwd(), '..', 'docs', 'public', 'docs', 'guides')+const GUIDES_MD_DIR = path.join(process.cwd(), '..', 'docs', 'public', 'markdown', 'guides')function getSources(): Source[] {const { sdkCsharp, sdkDart, sdkKotlin, sdkPython, sdkSwift } = isFeatureEnabled([@@ -37,6 +37,7 @@ function getSources(): Source[] {{ title: 'Supabase Reference (Python)', slug: 'python', enabled: sdkPython },{ title: 'Supabase Reference (C#)', slug: 'csharp', enabled: sdkCsharp },{ title: 'Supabase CLI Reference', slug: 'cli', enabled: true },+ { title: 'Supabase Management API Reference', slug: 'api', enabled: true },]}@@ -64,7 +65,7 @@ async function fetchSourceContent(slug: string): Promise<string | null> {const docsUrl = process.env.NEXT_PUBLIC_DOCS_URLif (!docsUrl) return null- const response = await fetch(`${docsUrl}/llms/${slug}.txt`)+ const response = await fetch(`${docsUrl}/markdown/reference/${slug}.md`)if (!response.ok) return nullreturn response.text()diff --git a/apps/www/app/llms.txt/route.ts b/apps/www/app/llms.txt/route.tsindex 12a6baeea4a..340c7eb7877 100644--- a/apps/www/app/llms.txt/route.ts+++ b/apps/www/app/llms.txt/route.ts@@ -68,6 +68,7 @@ async function getSources(): Promise<Source[]> {{ title: 'Supabase Reference (Python)', relPath: 'llms/python.txt', enabled: sdkPython },{ title: 'Supabase Reference (C#)', relPath: 'llms/csharp.txt', enabled: sdkCsharp },{ title: 'Supabase CLI Reference', relPath: 'llms/cli.txt', enabled: true },+ { title: 'Supabase Management API Reference', relPath: 'llms/api.txt', enabled: true },]}diff --git a/apps/www/app/llms/[slug]/route.ts b/apps/www/app/llms/[slug]/route.tsindex 08b6678478c..376a5186b46 100644--- a/apps/www/app/llms/[slug]/route.ts+++ b/apps/www/app/llms/[slug]/route.ts@@ -28,7 +28,8 @@ export async function GET(_request: Request, { params }: { params: Promise<{ sluconst docsUrl = process.env.NEXT_PUBLIC_DOCS_URLif (docsUrl) {- const response = await fetch(`${docsUrl}/llms/${slug}`)+ const filename = slug.replace(/\.txt$/, '.md')+ const response = await fetch(`${docsUrl}/markdown/reference/${filename}`)if (response.ok) {const content = await response.text()return textResponse(content)diff --git a/apps/www/next.config.mjs b/apps/www/next.config.mjsindex e23f23e0b98..9286c3c07af 100644--- a/apps/www/next.config.mjs+++ b/apps/www/next.config.mjs@@ -75,12 +75,12 @@ const nextConfig = {* /llms.txt enumerates top-level guide directories at runtime via fs.readdir* on apps/docs/content/guides and reads each <dir>.mdx for its frontmatter* title. /llms-full.txt recursively reads the generated .md files under- * apps/docs/public/docs/guides. Both directories live in a sibling app, so+ * apps/docs/public/markdown/. Both directories live in a sibling app, so* they have to be explicitly traced into this lambda's bundle.*/outputFileTracingIncludes: {'/llms.txt': ['../docs/content/guides/*'],- '/llms-full.txt': ['../docs/public/docs/guides/**/*.md'],+ '/llms-full.txt': ['../docs/public/markdown/guides/**/*.md' ],},reactStrictMode: true,images: {