mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
The www root markdown lived at an accidental URL: `/.md` served the
homepage markdown only because middleware strips the `.md` suffix and
the empty slug fell through to the homepage allowlist entry, while the
canonical-looking `/index.md` 404'd. The served markdown also opened
with stale legacy positioning copy that no longer matches the site. I
renamed the homepage content slug to `index` end-to-end so `/index.md`
is the one canonical markdown URL.
**Changed:**
- **`/index.md` serves the homepage markdown (200 `text/markdown`)**:
`content/md/homepage.md` renamed to `index.md`; the middleware bare-root
slug mapping, the generator's sort special-case, and the homepage
alternate tag follow, so the tag now advertises `/index.md`.
- **Legacy aliases 308 to the canonical URL**: `/.md`, `/homepage.md`,
and bare `/index` redirect via `lib/redirects.js`; `/llms/homepage.txt`
retargeted straight to `/index.md` to avoid a redirect chain. New
`next.config.test.ts` assertions pin all four.
- **Positioning refreshed**: the markdown now opens with "Supabase is
the Postgres development platform" (matching the site title), replacing
the outdated tagline.
- **Generator safety**: the redirect-exclusion filter in
`generateMdContent.mjs` now exempts the `index` slug (its HTML page is
`/`, not `/index`, so a `/index` redirect never refers to it), and the
build fails if `content/md/index.md` ever goes missing while middleware
still maps `/` to the `index` slug.
- **CI actually runs the new assertions**: I widened the `www-tests.yml`
paths filter to include `apps/www/lib/**/*.js`,
`apps/www/content/md/**`, and `apps/www/scripts/**/*.mjs`. It previously
only matched `.ts*` and the next.config files, so a PR touching only
`lib/redirects.js`, the markdown content, or the generator would skip
the tests that pin these redirects.
**Note:** the existing homepage alternate tag still exists, re-pointed
to the canonical URL. Whether the homepage should advertise a markdown
sibling at all is a separate decision; leaving it aimed at a 308 would
break tag consumers. Positioning wording is editorial, happy to tweak.
## To test
Tested on Vercel preview:
- [x] `curl -si <preview>/index.md`: expect 200 `content-type:
text/markdown`, body opens with the Postgres development platform
positioning and no longer contains the old tagline
- [x] `curl -sI <preview>/.md`: expect 308 with `location: /index.md`
- [x] `curl -sI <preview>/homepage.md` and `curl -sI
<preview>/llms/homepage.txt`: expect 308 with `location: /index.md`
- [x] `curl -sI <preview>/index`: expect 308 with `location: /`
- [x] `curl -s -H "Accept: text/markdown" -o /dev/null -w "%{http_code}
%{content_type}" <preview>/`: expect `200 text/markdown` (bare-URL
negotiation unchanged)
- [x] `curl -s <preview>/ | grep -o 'type="text/markdown"
href="[^"]*"'`: expect href ending `/index.md`
## Linear
- fixes GROWTH-1117
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added support for `/index.md` as the canonical Markdown representation
of the homepage.
- Added permanent redirects for legacy homepage Markdown and text URLs.
- Added `/index` to `/` redirect handling.
- **Bug Fixes**
- Updated homepage metadata, alternate links, Markdown negotiation, and
content generation to consistently use the new canonical path.
- Improved homepage content description.
- **Tests**
- Expanded coverage for homepage Markdown routes, redirects, and URL
matching.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
127 lines
4.2 KiB
TypeScript
127 lines
4.2 KiB
TypeScript
import '@code-hike/mdx/styles.css'
|
|
import 'config/code-hike.css'
|
|
import '../styles/globals.css'
|
|
import './launch-week/launchWeek.css'
|
|
|
|
import { inter, manrope, sourceCodePro } from '~/lib/fonts'
|
|
import {
|
|
AuthProvider,
|
|
FeatureFlagProvider,
|
|
IS_PLATFORM,
|
|
PageTelemetry,
|
|
TelemetryTagManager,
|
|
ThemeProvider,
|
|
useThemeSandbox,
|
|
} from 'common'
|
|
import MetaFaviconsPagesRouter, {
|
|
DEFAULT_FAVICON_ROUTE,
|
|
DEFAULT_FAVICON_THEME_COLOR,
|
|
} from 'common/MetaFavicons/pages-router'
|
|
import { DevToolbar, DevToolbarProvider } from 'dev-tools'
|
|
import { DefaultSeo } from 'next-seo'
|
|
import type { AppProps } from 'next/app'
|
|
import Head from 'next/head'
|
|
import { useRouter } from 'next/router'
|
|
import { TooltipProvider } from 'ui'
|
|
import { CommandProvider } from 'ui-patterns/CommandMenu'
|
|
import { useConsentToast } from 'ui-patterns/consent'
|
|
|
|
import useDarkLaunchWeeks from '../hooks/useDarkLaunchWeeks'
|
|
import { useWwwCommandMenuTelemetry } from '../hooks/useWwwCommandMenuTelemetry'
|
|
import { MD_PAGES } from '@/app/api-v2/md/content.generated'
|
|
import { Toaster } from '@/app/toaster'
|
|
import { WwwCommandMenu } from '@/components/CommandMenu'
|
|
import { API_URL, APP_NAME, DEFAULT_META_DESCRIPTION } from '@/lib/constants'
|
|
|
|
export default function App({ Component, pageProps }: AppProps) {
|
|
const router = useRouter()
|
|
const { hasAcceptedConsent } = useConsentToast()
|
|
const { onTelemetry } = useWwwCommandMenuTelemetry()
|
|
|
|
useThemeSandbox()
|
|
|
|
const site_title = `${APP_NAME} | The Postgres Development Platform.`
|
|
const { basePath } = useRouter()
|
|
|
|
const isDarkLaunchWeek = useDarkLaunchWeeks()
|
|
const forceDarkMode = isDarkLaunchWeek
|
|
|
|
const applicationName = 'Supabase'
|
|
const faviconRoute = DEFAULT_FAVICON_ROUTE
|
|
const themeColor = DEFAULT_FAVICON_THEME_COLOR
|
|
|
|
// Advertise the .md version for AI agents on pages that have one.
|
|
const cleanPath = (router.asPath ?? '/').split('?')[0].split('#')[0].replace(/\/$/, '') || '/'
|
|
const mdSlug = cleanPath === '/' ? 'index' : cleanPath.slice(1)
|
|
const mdAlternateHref = MD_PAGES.has(mdSlug)
|
|
? cleanPath === '/'
|
|
? '/index.md'
|
|
: `${cleanPath}.md`
|
|
: null
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
{mdAlternateHref && <link rel="alternate" type="text/markdown" href={mdAlternateHref} />}
|
|
</Head>
|
|
<MetaFaviconsPagesRouter
|
|
applicationName={applicationName}
|
|
route={faviconRoute}
|
|
themeColor={themeColor}
|
|
includeManifest
|
|
includeMsApplicationConfig
|
|
includeRssXmlFeed
|
|
/>
|
|
<DefaultSeo
|
|
title={site_title}
|
|
description={DEFAULT_META_DESCRIPTION}
|
|
openGraph={{
|
|
type: 'website',
|
|
url: 'https://supabase.com/',
|
|
site_name: 'Supabase',
|
|
images: [
|
|
{
|
|
url: `https://supabase.com${basePath}/images/og/supabase-og.png`,
|
|
width: 800,
|
|
height: 600,
|
|
alt: 'Supabase Og Image',
|
|
},
|
|
],
|
|
}}
|
|
twitter={{
|
|
handle: '@supabase',
|
|
site: '@supabase',
|
|
cardType: 'summary_large_image',
|
|
}}
|
|
/>
|
|
|
|
<div className={`${manrope.variable} ${inter.variable} ${sourceCodePro.variable}`}>
|
|
<AuthProvider>
|
|
{/* [TODO] I think we need to deconflict with the providers in layout.tsx? */}
|
|
<FeatureFlagProvider API_URL={API_URL} enabled={{ cc: true, ph: false }}>
|
|
<DevToolbarProvider apiUrl={API_URL}>
|
|
<ThemeProvider forcedTheme={forceDarkMode ? 'dark' : undefined}>
|
|
<TooltipProvider delayDuration={0}>
|
|
<CommandProvider app="www" onTelemetry={onTelemetry}>
|
|
<Toaster />
|
|
<Component {...pageProps} />
|
|
<WwwCommandMenu />
|
|
<PageTelemetry
|
|
API_URL={API_URL}
|
|
hasAcceptedConsent={hasAcceptedConsent}
|
|
enabled={IS_PLATFORM}
|
|
/>
|
|
<DevToolbar />
|
|
</CommandProvider>
|
|
</TooltipProvider>
|
|
</ThemeProvider>
|
|
</DevToolbarProvider>
|
|
</FeatureFlagProvider>
|
|
</AuthProvider>
|
|
<TelemetryTagManager />
|
|
</div>
|
|
</>
|
|
)
|
|
}
|