Files
supabase/apps/www/lib/go.ts
T
Alan Daniel 32330e26c0 New Campaign Pages: /go (#42920)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES/NO

## What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.
2026-02-23 15:47:03 +00:00

35 lines
941 B
TypeScript

import rawPages from '@/_go'
import { goPageSchema, type GoPage } from '@/types/go'
export function getAllGoPages(): GoPage[] {
const pages: GoPage[] = []
const seenSlugs = new Set<string>()
for (const raw of rawPages) {
const result = goPageSchema.safeParse(raw)
if (!result.success) {
throw new Error(
`Invalid go page definition (slug: "${(raw as any).slug ?? 'unknown'}"):\n${result.error.issues.map((i) => ` - ${i.path.join('.')}: ${i.message}`).join('\n')}`
)
}
if (seenSlugs.has(result.data.slug)) {
throw new Error(`Duplicate slug "${result.data.slug}" in _go registry`)
}
seenSlugs.add(result.data.slug)
pages.push(result.data)
}
return pages
}
export function getAllGoSlugs(): string[] {
return getAllGoPages().map((p) => p.slug)
}
export function getGoPageBySlug(slug: string): GoPage | undefined {
return getAllGoPages().find((p) => p.slug === slug)
}