The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(docs): make page title customizable via feature flag (#39415)
Charisf9ea453fc6fa
diff --git a/apps/docs/app/guides/getting-started/ai-prompts/[slug]/AiPrompts.utils.ts b/apps/docs/app/guides/getting-started/ai-prompts/[slug]/AiPrompts.utils.tsindex c79f8ac313b..bd82fbd4621 100644--- a/apps/docs/app/guides/getting-started/ai-prompts/[slug]/AiPrompts.utils.ts+++ b/apps/docs/app/guides/getting-started/ai-prompts/[slug]/AiPrompts.utils.ts@@ -6,9 +6,12 @@ import { readdir, readFile, stat } from 'node:fs/promises'import { basename, extname, join } from 'node:path'import { cache } from 'react'import { visit, EXIT } from 'unist-util-visit'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'import { EXAMPLES_DIRECTORY } from '~/lib/docs'+const { metadataTitle } = getCustomContent(['metadata:title'])+const PROMPTS_DIRECTORY = join(EXAMPLES_DIRECTORY, 'prompts')function parseMarkdown(markdown: string) {@@ -85,7 +88,7 @@ export async function generateAiPromptMetadata(props: { params: Promise<{ slug:if (!prompt) {return {- title: 'AI Prompt | Supabase Docs',+ title: `AI Prompt | ${metadataTitle || 'Supabase'}`,}}diff --git a/apps/docs/app/guides/troubleshooting/[slug]/page.tsx b/apps/docs/app/guides/troubleshooting/[slug]/page.tsxindex d56363997a1..9f15cac7d53 100644--- a/apps/docs/app/guides/troubleshooting/[slug]/page.tsx+++ b/apps/docs/app/guides/troubleshooting/[slug]/page.tsx@@ -3,11 +3,12 @@ import { notFound } from 'next/navigation'import TroubleshootingPage from '~/features/docs/Troubleshooting.page'import { getAllTroubleshootingEntries, getArticleSlug } from '~/features/docs/Troubleshooting.utils'import { PROD_URL } from '~/lib/constants'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'-// 60 seconds/minute * 60 minutes/hour * 24 hours/day-// export const revalidate = 86_400export const dynamicParams = false+const { metadataTitle } = getCustomContent(['metadata:title'])+export default async function TroubleshootingEntryPage(props: {params: Promise<{ slug: string }>}) {@@ -34,7 +35,7 @@ export const generateMetadata = async (props: { params: Promise<{ slug: string }const entry = allTroubleshootingEntries.find((entry) => getArticleSlug(entry) === slug)return {- title: 'Supabase Docs | Troubleshooting' + (entry ? ` | ${entry.data.title}` : ''),+ title: `${metadataTitle || 'Supabase'} | Troubleshooting${entry ? ` | ${entry.data.title}` : ''}`,alternates: {canonical: `${PROD_URL}/guides/troubleshooting/${slug}`,},diff --git a/apps/docs/app/guides/troubleshooting/page.tsx b/apps/docs/app/guides/troubleshooting/page.tsxindex 1a519cf26b0..74582ef4838 100644--- a/apps/docs/app/guides/troubleshooting/page.tsx+++ b/apps/docs/app/guides/troubleshooting/page.tsx@@ -15,9 +15,9 @@ import {import { TROUBLESHOOTING_CONTAINER_ID } from '~/features/docs/Troubleshooting.utils.shared'import { SidebarSkeleton } from '~/layouts/MainSkeleton'import { PROD_URL } from '~/lib/constants'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'-// 60 seconds/minute * 60 minutes/hour * 24 hours/day-// export const revalidate = 86_400+const { metadataTitle } = getCustomContent(['metadata:title'])export default async function GlobalTroubleshootingPage() {const troubleshootingEntries = await getAllTroubleshootingEntries()@@ -60,7 +60,7 @@ export default async function GlobalTroubleshootingPage() {}export const metadata: Metadata = {- title: 'Supabase Docs | Troubleshooting',+ title: `${metadataTitle || 'Supabase'} | Troubleshooting`,alternates: {canonical: `${PROD_URL}/guides/troubleshooting`,},diff --git a/apps/docs/app/layout.tsx b/apps/docs/app/layout.tsxindex 420f18093ce..353f4a60b74 100644--- a/apps/docs/app/layout.tsx+++ b/apps/docs/app/layout.tsx@@ -4,18 +4,23 @@ import '../styles/main.scss'import '../styles/new-docs.scss'import '../styles/prism-okaidia.scss'-import { type Metadata, type Viewport } from 'next'+import { TelemetryTagManager } from 'common'import { genFaviconData } from 'common/MetaFavicons/app-router'-+import type { Metadata, Viewport } from 'next'import { GlobalProviders } from '~/features/app.providers'import { TopNavSkeleton } from '~/layouts/MainSkeleton'import { BASE_PATH, IS_PRODUCTION } from '~/lib/constants'-import { TelemetryTagManager } from 'common'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'++const { metadataApplicationName, metadataTitle } = getCustomContent([+ 'metadata:application_name',+ 'metadata:title',+])const metadata: Metadata = {- applicationName: 'Supabase Docs',- title: 'Supabase Docs',+ applicationName: metadataApplicationName,+ title: metadataTitle,description:'Supabase is the Postgres development platform providing all the backend features you need to build a product.',metadataBase: new URL('https://supabase.com'),diff --git a/apps/docs/components/HomePageCover.tsx b/apps/docs/components/HomePageCover.tsxindex 5e35276d153..597634f91a3 100644--- a/apps/docs/components/HomePageCover.tsx+++ b/apps/docs/components/HomePageCover.tsx@@ -7,7 +7,7 @@ import Link from 'next/link'import { isFeatureEnabled, useBreakpoint } from 'common'import { cn, IconBackground } from 'ui'import { IconPanel } from 'ui-patterns/IconPanel'-import { useCustomContent } from '../hooks/custom-content/useCustomContent'+import { getCustomContent } from '../lib/custom-content/getCustomContent'import DocsCoverLogo from './DocsCoverLogo'const { sdkDart: sdkDartEnabled, sdkKotlin: sdkKotlinEnabled } = isFeatureEnabled([@@ -37,7 +37,7 @@ function AiPrompt({ className }: { className?: string }) {const HomePageCover = (props) => {const isXs = useBreakpoint(639)const iconSize = isXs ? 'sm' : 'lg'- const { homepageHeading } = useCustomContent(['homepage:heading'])+ const { homepageHeading } = getCustomContent(['homepage:heading'])const frameworks = [{diff --git a/apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx b/apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsxindex 1ae88b582ae..0a4600478c2 100644--- a/apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx@@ -9,7 +9,7 @@ import { memo, useState } from 'react'import { useIsLoggedIn, useIsUserLoading, useUser } from 'common'import { Button, buttonVariants, cn } from 'ui'import { AuthenticatedDropdownMenu, CommandMenuTrigger } from 'ui-patterns'-import { useCustomContent } from '../../../hooks/custom-content/useCustomContent'+import { getCustomContent } from '../../../lib/custom-content/getCustomContent'import GlobalNavigationMenu from './GlobalNavigationMenu'import useDropdownMenu from './useDropdownMenu'@@ -110,7 +110,7 @@ const TopNavBar: FC = () => {}const HeaderLogo = memo(() => {- const { navigationLogo } = useCustomContent(['navigation:logo'])+ const { navigationLogo } = getCustomContent(['navigation:logo'])return (<Linkdiff --git a/apps/docs/features/docs/GuidesMdx.utils.tsx b/apps/docs/features/docs/GuidesMdx.utils.tsxindex b6c7a774231..23457ffdf14 100644--- a/apps/docs/features/docs/GuidesMdx.utils.tsx+++ b/apps/docs/features/docs/GuidesMdx.utils.tsx@@ -17,6 +17,9 @@ import { GUIDES_DIRECTORY, isValidGuideFrontmatter, type GuideFrontmatter } fromimport { GuideModelLoader } from '~/resources/guide/guideModelLoader'import { newEditLink } from './GuidesMdx.template'import { checkGuidePageEnabled } from './NavigationPageStatus.utils'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'++const { metadataTitle } = getCustomContent(['metadata:title'])const PUBLISHED_SECTIONS = ['ai',@@ -170,7 +173,7 @@ const genGuideMeta =const ogType = pathname.split('/')[2]return {- title: `${meta.title} | Supabase Docs`,+ title: `${meta.title} | ${metadataTitle || 'Supabase'}`,description: meta.description || meta.subtitle,// @ts-ignorealternates: {diff --git a/apps/docs/features/docs/Reference.utils.ts b/apps/docs/features/docs/Reference.utils.tsindex b29cbf13ec6..ae3633e5aca 100644--- a/apps/docs/features/docs/Reference.utils.ts+++ b/apps/docs/features/docs/Reference.utils.ts@@ -6,10 +6,13 @@ import type { Metadata, ResolvingMetadata } from 'next'import { redirect } from 'next/navigation'import { visit } from 'unist-util-visit'-import { REFERENCES, clientSdkIds, selfHostingServices } from '~/content/navigation.references'+import { clientSdkIds, REFERENCES, selfHostingServices } from '~/content/navigation.references'import { getFlattenedSections } from '~/features/docs/Reference.generated.singleton'import { generateOpenGraphImageMeta } from '~/features/seo/openGraph'import { BASE_PATH } from '~/lib/constants'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'++const { metadataTitle } = getCustomContent(['metadata:title'])export interface AbbrevApiReferenceSection {id: string@@ -155,7 +158,7 @@ export async function generateReferenceMetadata(})return {- title: `${displayName} API Reference | Supabase Docs`,+ title: `${displayName} API Reference | ${metadataTitle || 'Supabase'}`,description: `API reference for the ${displayName} Supabase SDK`,...(slug.length > 0? {diff --git a/apps/docs/features/docs/TroubleshootingSection.page.tsx b/apps/docs/features/docs/TroubleshootingSection.page.tsxindex 9358ca24b19..9fdeb8b6173 100644--- a/apps/docs/features/docs/TroubleshootingSection.page.tsx+++ b/apps/docs/features/docs/TroubleshootingSection.page.tsx@@ -12,6 +12,9 @@ import {getTroubleshootingKeywordsByTopic,} from '~/features/docs/Troubleshooting.utils'import { PROD_URL } from '~/lib/constants'+import { getCustomContent } from '~/lib/custom-content/getCustomContent'++const { metadataTitle } = getCustomContent(['metadata:title'])interface SectionTroubleshootingPageProps {topic: ITroubleshootingMetadata['topics'][number]@@ -60,7 +63,7 @@ export function generateSectionTroubleshootingMetadata(sectionName: string): Metadata {return {- title: `Supabase Docs | ${sectionName} Troubleshooting`,+ title: `${metadataTitle ?? 'Supabase'} | ${sectionName} Troubleshooting`,alternates: {canonical: `${PROD_URL}/guides/${topic}/troubleshooting`,},diff --git a/apps/docs/hooks/custom-content/CustomContent.types.ts b/apps/docs/lib/custom-content/CustomContent.types.tssimilarity index 73%rename from apps/docs/hooks/custom-content/CustomContent.types.tsrename to apps/docs/lib/custom-content/CustomContent.types.tsindex ce845cef5b5..1554064ed77 100644--- a/apps/docs/hooks/custom-content/CustomContent.types.ts+++ b/apps/docs/lib/custom-content/CustomContent.types.ts@@ -1,5 +1,7 @@export type CustomContentTypes = {homepageHeading: string+ metadataApplicationName: string+ metadataTitle: stringnavigationLogo: {light: stringdark: stringdiff --git a/apps/docs/hooks/custom-content/custom-content.json b/apps/docs/lib/custom-content/custom-content.jsonsimilarity index 65%rename from apps/docs/hooks/custom-content/custom-content.jsonrename to apps/docs/lib/custom-content/custom-content.jsonindex 71c31154842..54504e90117 100644--- a/apps/docs/hooks/custom-content/custom-content.json+++ b/apps/docs/lib/custom-content/custom-content.json@@ -1,5 +1,7 @@{"homepage:heading": "Supabase Documentation",+ "metadata:application_name": "Supabase Docs",+ "metadata:title": "Supabase Docs","navigation:logo": {"light": "/docs/supabase-light.svg","dark": "/docs/supabase-dark.svg"diff --git a/apps/docs/hooks/custom-content/useCustomContent.test.ts b/apps/docs/lib/custom-content/getCustomContent.test.tssimilarity index 57%rename from apps/docs/hooks/custom-content/useCustomContent.test.tsrename to apps/docs/lib/custom-content/getCustomContent.test.tsindex 38145d93f5f..c48f5413e62 100644--- a/apps/docs/hooks/custom-content/useCustomContent.test.ts+++ b/apps/docs/lib/custom-content/getCustomContent.test.ts@@ -1,17 +1,11 @@-/*- * @vitest-environment jsdom- */--import { cleanup, renderHook } from '@testing-library/react'import { beforeEach, describe, expect, it, vi } from 'vitest'beforeEach(() => {vi.clearAllMocks()vi.resetModules()- cleanup()})-describe('useCustomContent', () => {+describe('getCustomContent', () => {it('should return null if content is not found in the custom-content.json file', async () => {vi.doMock('./custom-content.json', () => ({default: {@@ -19,9 +13,9 @@ describe('useCustomContent', () => {},}))- const { useCustomContent } = await import('./useCustomContent')- const { result } = renderHook(() => useCustomContent(['navigation:logo']))- expect(result.current.navigationLogo).toEqual(null)+ const { getCustomContent } = await import('./getCustomContent')+ const result = getCustomContent(['navigation:logo'])+ expect(result.navigationLogo).toEqual(null)})it('should return the content for the key passed in if it exists in the custom-content.json file', async () => {@@ -35,12 +29,12 @@ describe('useCustomContent', () => {},}))- const { useCustomContent } = await import('./useCustomContent')- const { result } = renderHook(() => useCustomContent(['navigation:logo', 'homepage:heading']))- expect(result.current.navigationLogo).toEqual({+ const { getCustomContent } = await import('./getCustomContent')+ const result = getCustomContent(['navigation:logo', 'homepage:heading'])+ expect(result.navigationLogo).toEqual({light: 'https://example.com/logo-light.svg',dark: 'https://example.com/logo-dark.svg',})- expect(result.current.homepageHeading).toEqual('Custom Heading')+ expect(result.homepageHeading).toEqual('Custom Heading')})})diff --git a/apps/docs/hooks/custom-content/useCustomContent.ts b/apps/docs/lib/custom-content/getCustomContent.tssimilarity index 60%rename from apps/docs/hooks/custom-content/useCustomContent.tsrename to apps/docs/lib/custom-content/getCustomContent.tsindex d88a73339a1..07e327f4fbf 100644--- a/apps/docs/hooks/custom-content/useCustomContent.ts+++ b/apps/docs/lib/custom-content/getCustomContent.ts@@ -1,17 +1,8 @@-/*- * [Charis 2025-09-29] This file is a duplicate of studio's useCustomContent.ts- * for now.- *- * We should probably consolidate these two files in the future, but we want to- * get this change shipped quickly without worrying about smoke testing all the- * components affected by a refactor.- */-import type { CustomContentTypes } from './CustomContent.types'import customContentRaw from './custom-content.json'const customContentStaticObj = customContentRaw as Omit<typeof customContentRaw, '$schema'>-type CustomContent = keyof typeof customContentStaticObj+export type CustomContent = keyof typeof customContentStaticObjtype SnakeToCamelCase<S extends string> = S extends `${infer First}_${infer Rest}`? `${First}${SnakeToCamelCase<Capitalize<Rest>>}`@@ -29,21 +20,16 @@ function contentToCamelCase(feature: CustomContent) {.join('') as CustomContentToCamelCase<typeof feature>}-const useCustomContent = <T extends CustomContent[]>(- contents: T-): {+type CustomContentResult<T extends CustomContent[]> = {[key in CustomContentToCamelCase<T[number]>]:| CustomContentTypes[CustomContentToCamelCase<T[number]>]| null-} => {- // [Joshen] Running into some TS errors without the `as` here - must be overlooking something super simple+}++export const getCustomContent = <T extends CustomContent[]>(+ contents: T+): CustomContentResult<T> => {return Object.fromEntries(contents.map((content) => [contentToCamelCase(content), customContentStaticObj[content]])- ) as {- [key in CustomContentToCamelCase<T[number]>]:- | CustomContentTypes[CustomContentToCamelCase<T[number]>]- | null- }+ ) as CustomContentResult<T>}--export { useCustomContent }diff --git a/apps/docs/scripts/llms.ts b/apps/docs/scripts/llms.tsindex 9d68e431ed6..95ad95d57ef 100644--- a/apps/docs/scripts/llms.ts+++ b/apps/docs/scripts/llms.ts@@ -4,7 +4,8 @@ import 'dotenv/config'import fs from 'node:fs/promises'import { fileURLToPath } from 'node:url'-import { isFeatureEnabled } from 'common/enabled-features'+import { isFeatureEnabled } from '../../../packages/common/enabled-features/index.js'+import { getCustomContent } from '../lib/custom-content/getCustomContent.js'import {fetchCliLibReferenceSource,fetchCSharpLibReferenceSource,@@ -35,6 +36,8 @@ const {sdkSwift: sdkSwiftEnabled,} = isFeatureEnabled(['sdk:csharp', 'sdk:dart', 'sdk:kotlin', 'sdk:python', 'sdk:swift'])+const { metadataTitle } = getCustomContent(['metadata:title'])+function toLink(source: Source) {return `[${source.title}](https://supabase.com/${source.relPath})`}@@ -115,7 +118,7 @@ async function generateMainLlmsTxt() {const sourceLinks = SOURCES.filter((source) => source.enabled !== false).map((source) => `- ${toLink(source)}`).join('\n')- const fullText = `# Supabase Docs\n\n${sourceLinks}`+ const fullText = `# ${metadataTitle}\n\n${sourceLinks}`fs.writeFile('public/llms.txt', fullText)}