The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: don't render hidden pages (#38477)
Chariseed0f6e7ce11
diff --git a/apps/docs/app/reference/[...slug]/page.tsx b/apps/docs/app/reference/[...slug]/page.tsxindex 2c7bb70463b..0ed5497704c 100644--- a/apps/docs/app/reference/[...slug]/page.tsx+++ b/apps/docs/app/reference/[...slug]/page.tsx@@ -33,6 +33,10 @@ export default async function ReferencePage(props: { params: Promise<{ slug: Arrconst { sdkId, maybeVersion, path } = parsedPathconst sdkData = REFERENCES[sdkId]+ if (sdkData.enabled === false) {+ notFound()+ }+const latestVersion = sdkData.versions[0]const version = maybeVersion ?? latestVersiondiff --git a/apps/docs/components/Navigation/Navigation.types.ts b/apps/docs/components/Navigation/Navigation.types.tsindex 7918a38e68e..816a5b363b0 100644--- a/apps/docs/components/Navigation/Navigation.types.ts+++ b/apps/docs/components/Navigation/Navigation.types.ts@@ -11,6 +11,9 @@ export interface NavMenuSection {name: stringurl?: `/${string}` | `https://${string}`items: Partial<NavMenuSection>[]+ icon?: string+ hasLightIcon?: boolean+ isDarkMode?: booleanenabled?: boolean}diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex ea41b02c326..0ba7046740b 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -1,6 +1,6 @@import type { ComponentProps } from 'react'-import { isFeatureEnabled } from 'common'+import { isFeatureEnabled } from 'common/enabled-features'import type { IconPanel } from 'ui-patterns/IconPanel'import type { GlobalMenuItems, NavMenuConstant, NavMenuSection } from '../Navigation.types'@@ -460,7 +460,7 @@ export const NativeMobileLoginItems = [},]-export const SocialLoginItems = [+export const SocialLoginItems: Array<Partial<NavMenuSection>> = [{name: 'Google',icon: '/docs/img/icons/google-icon',@@ -591,7 +591,7 @@ export const PhoneLoginsItems = [},]-export const auth = {+export const auth: NavMenuConstant = {icon: 'auth',title: 'Auth',items: [@@ -1865,7 +1865,7 @@ export const storage: NavMenuConstant = {],}-export const vectorIndexItems = [+export const vectorIndexItems: Array<Partial<NavMenuSection>> = [{name: 'HNSW indexes',url: '/guides/ai/vector-indexes/hnsw-indexes',@@ -1876,7 +1876,7 @@ export const vectorIndexItems = [},]-export const ai = {+export const ai: NavMenuConstant = {icon: 'ai',title: 'AI & Vectors',url: '/guides/ai',diff --git a/apps/docs/content/navigation.references.ts b/apps/docs/content/navigation.references.tsindex e3b02e54ab0..fb619cb0539 100644--- a/apps/docs/content/navigation.references.ts+++ b/apps/docs/content/navigation.references.ts@@ -1,3 +1,13 @@+import { isFeatureEnabled } from 'common/enabled-features'++const {+ sdkCsharp: sdkCsharpEnabled,+ sdkDart: sdkDartEnabled,+ sdkKotlin: sdkKotlinEnabled,+ sdkPython: sdkPythonEnabled,+ sdkSwift: sdkSwiftEnabled,+} = isFeatureEnabled(['sdk:csharp', 'sdk:dart', 'sdk:kotlin', 'sdk:python', 'sdk:swift'])+export const REFERENCES = {javascript: {type: 'sdk',@@ -35,6 +45,7 @@ export const REFERENCES = {specFile: 'supabase_dart_v1',},},+ enabled: sdkDartEnabled,},csharp: {type: 'sdk',@@ -53,6 +64,7 @@ export const REFERENCES = {specFile: 'supabase_csharp_v0',},},+ enabled: sdkCsharpEnabled,},swift: {type: 'sdk',@@ -71,6 +83,7 @@ export const REFERENCES = {specFile: 'supabase_swift_v1',},},+ enabled: sdkSwiftEnabled,},kotlin: {type: 'sdk',@@ -93,6 +106,7 @@ export const REFERENCES = {specFile: 'supabase_kt_v1',},},+ enabled: sdkKotlinEnabled,},python: {type: 'sdk',@@ -107,6 +121,7 @@ export const REFERENCES = {specFile: 'supabase_py_v2',},},+ enabled: sdkPythonEnabled,},cli: {type: 'cli',@@ -160,7 +175,7 @@ export const REFERENCES = {} as constexport const clientSdkIds = Object.keys(REFERENCES).filter(- (reference) => REFERENCES[reference].type === 'sdk'+ (reference) => REFERENCES[reference].type === 'sdk' && REFERENCES[reference].enabled !== false)export const selfHostingServices = Object.keys(REFERENCES).filter(diff --git a/apps/docs/features/docs/GuidesMdx.utils.tsx b/apps/docs/features/docs/GuidesMdx.utils.tsxindex 50b5dede231..b6c7a774231 100644--- a/apps/docs/features/docs/GuidesMdx.utils.tsx+++ b/apps/docs/features/docs/GuidesMdx.utils.tsx@@ -16,6 +16,7 @@ import { BASE_PATH } from '~/lib/constants'import { GUIDES_DIRECTORY, isValidGuideFrontmatter, type GuideFrontmatter } from '~/lib/docs'import { GuideModelLoader } from '~/resources/guide/guideModelLoader'import { newEditLink } from './GuidesMdx.template'+import { checkGuidePageEnabled } from './NavigationPageStatus.utils'const PUBLISHED_SECTIONS = ['ai',@@ -42,6 +43,8 @@ const PUBLISHED_SECTIONS = [const getGuidesMarkdownInternal = async (slug: string[]) => {const relPath = slug.join(sep).replace(/\/$/, '')const fullPath = join(GUIDES_DIRECTORY, relPath + '.mdx')+ const guidesPath = `/guides/${slug.join('/')}`+/*** SAFETY CHECK:* Prevent accessing anything outside of published sections and GUIDES_DIRECTORY@@ -53,6 +56,15 @@ const getGuidesMarkdownInternal = async (slug: string[]) => {notFound()}+ /**+ * DISABLED PAGE CHECK:+ * Check if this page is disabled in the navigation configuration+ */+ if (!checkGuidePageEnabled(guidesPath)) {+ console.log('Page is disabled: %s', guidesPath)+ notFound()+ }+try {const guide = (await GuideModelLoader.fromFs(relative(GUIDES_DIRECTORY, fullPath))).unwrap()const content = guide.content ?? ''@@ -121,12 +133,25 @@ const genGuidesStaticParams = (directory?: string) => async () => {))+ // Flattening earlier will not work because there is nothing to flatten+ // until the promises resolve.+ const allParams = (await Promise.all(promises)).flat()+/**- * Flattening earlier will not work because there is nothing to flatten- * until the promises resolve.+ * Filter out disabled pages from static generation*/- const result = (await Promise.all(promises)).flat()- return result+ const enabledParams = allParams.filter((param) => {+ const guidesPath = `/guides/${directory ? `${directory}/` : ''}${param.slug.join('/')}`+ const isEnabled = checkGuidePageEnabled(guidesPath)++ if (!isEnabled) {+ console.log('Excluding disabled page from static generation: %s', guidesPath)+ }++ return isEnabled+ })++ return enabledParams}const genGuideMeta =diff --git a/apps/docs/features/docs/NavigationPageStatus.utils.ts b/apps/docs/features/docs/NavigationPageStatus.utils.tsnew file mode 100644index 00000000000..6968e1e23aa--- /dev/null+++ b/apps/docs/features/docs/NavigationPageStatus.utils.ts@@ -0,0 +1,130 @@+import { type NavMenuConstant } from '~/components/Navigation/Navigation.types'+import {+ GLOBAL_MENU_ITEMS,+ ai,+ api,+ auth,+ cron,+ database,+ deployment,+ functions,+ gettingstarted,+ graphql,+ integrations,+ local_development,+ platform,+ queues,+ realtime,+ security,+ self_hosting,+ storage,+ telemetry,+} from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'++// Map of section names to their nav constants+const SECTION_NAV_MAPS: Record<string, NavMenuConstant> = {+ ai,+ api,+ auth,+ cron,+ database,+ deployment,+ functions,+ 'getting-started': gettingstarted,+ graphql,+ integrations,+ 'local-development': local_development,+ platform,+ queues,+ realtime,+ security,+ 'self-hosting': self_hosting,+ storage,+ telemetry,+}++interface ConditionalNavItem {+ url?: string+ href?: string+ enabled?: boolean+ items?: Readonly<ConditionalNavItem[]>+ menuItems?: Readonly<ConditionalNavItem[][]>+}++/**+ * Recursively walks navigation items and collects all disabled paths.+ * If a parent is disabled, all its children are also considered disabled.+ */+function collectDisabledPaths(+ items: Readonly<ConditionalNavItem[] | ConditionalNavItem[][]>,+ disabledPaths: Set<string>,+ parentDisabled: boolean = false+): void {+ for (const item of items) {+ if (Array.isArray(item)) {+ // Handle nested arrays (like in GLOBAL_MENU_ITEMS)+ collectDisabledPaths(item, disabledPaths, parentDisabled)+ } else {+ const isCurrentDisabled = parentDisabled || item.enabled === false+ const itemUrl = item.url || item.href++ if (itemUrl && itemUrl.startsWith('/guides/')) {+ const normalizedUrl = normalizeUrl(itemUrl)+ if (isCurrentDisabled) {+ disabledPaths.add(normalizedUrl)+ }+ }++ // Recursively check children, passing down the disabled status+ if (item.items) {+ collectDisabledPaths(item.items, disabledPaths, isCurrentDisabled)+ }+ if (item.menuItems) {+ collectDisabledPaths(item.menuItems, disabledPaths, isCurrentDisabled)+ }+ }+ }+}++/**+ * Normalizes URLs for comparison by removing leading/trailing slashes and ensuring consistent format+ */+function normalizeUrl(url: string): string {+ return url.replace(/^\/+|\/+$/g, '').toLowerCase()+}++/**+ * Creates and caches the set of all disabled guide paths.+ * This is computed once and reused across all checks.+ */+let cachedDisabledPaths: Set<string> | null = null++function getDisabledGuidePaths(): Set<string> {+ if (cachedDisabledPaths === null) {+ cachedDisabledPaths = new Set<string>()++ // Collect disabled paths from global menu items+ collectDisabledPaths(GLOBAL_MENU_ITEMS, cachedDisabledPaths)++ // Collect disabled paths from section-specific navigation+ Object.values(SECTION_NAV_MAPS).forEach((sectionNav) => {+ if (sectionNav.items) {+ collectDisabledPaths([sectionNav], cachedDisabledPaths!)+ }+ })+ }++ return cachedDisabledPaths+}++/**+ * Checks if a guides page is enabled based on the navigation menu configuration+ *+ * @param guidesPath - The path to the guides page (e.g., "/guides/auth/users")+ * @returns true if enabled, false if disabled+ */+export function checkGuidePageEnabled(guidesPath: string): boolean {+ const disabledPaths = getDisabledGuidePaths()+ const normalizedPath = normalizeUrl(guidesPath)+ return !disabledPaths.has(normalizedPath)+}diff --git a/apps/docs/middleware.ts b/apps/docs/middleware.tsindex cdc560edfc6..919802bbdf5 100644--- a/apps/docs/middleware.ts+++ b/apps/docs/middleware.ts@@ -1,5 +1,6 @@import { isbot } from 'isbot'import { type NextRequest, NextResponse } from 'next/server'+import { clientSdkIds } from '~/content/navigation.references'import { BASE_PATH } from '~/lib/constants'diff --git a/apps/docs/resources/guide/guideModelLoader.ts b/apps/docs/resources/guide/guideModelLoader.tsindex 4ba9674de1e..5af209f9f38 100644--- a/apps/docs/resources/guide/guideModelLoader.ts+++ b/apps/docs/resources/guide/guideModelLoader.ts@@ -1,9 +1,10 @@import matter from 'gray-matter'import { promises as fs } from 'node:fs'-import { join, relative } from 'node:path'+import { join, relative, resolve } from 'node:path'import { extractMessageFromAnyError, FileNotFoundError, MultiError } from '~/app/api/utils'import { preprocessMdxWithDefaults } from '~/features/directives/utils'+import { checkGuidePageEnabled } from '~/features/docs/NavigationPageStatus.utils'import { Both, Result } from '~/features/helpers.fn'import { GUIDES_DIRECTORY } from '~/lib/docs'import { processMdx } from '~/scripts/helpers.mdx'@@ -19,6 +20,24 @@ function isHiddenFile(path: string): boolean {return path.split('/').some((part) => part.startsWith('_'))}+/**+ * Determines if a guide file is disabled in the navigation configuration.+ *+ * @param relPath - Relative path to the .mdx file within the base directory+ * @param baseDir - Base directory to calculate relPath from+ * @returns true if the page is disabled, false if enabled+ */+function isDisabledGuide(relPath: string, baseDir: string): boolean {+ const fullPath = resolve(baseDir, relPath)+ if (!fullPath.startsWith(GUIDES_DIRECTORY)) return false++ const relGuidePath = relative(GUIDES_DIRECTORY, fullPath)+ const urlPath = relGuidePath.replace(/\.mdx?$/, '').replace(/\/index$/, '')+ const guidesPath = `/guides/${urlPath}`++ return !checkGuidePageEnabled(guidesPath)+}+/*** Recursively walks a directory and collects all .mdx files that are not hidden.*/@@ -40,7 +59,10 @@ async function walkMdxFiles(continue}- // Only include .mdx files+ if (isDisabledGuide(relativePath, dir)) {+ continue+ }+if (relativePath.endsWith('.mdx')) {mdxFiles.push(join(dir, relativePath))}