mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Closes DOCS-1756 ## Problem No docs page tells an agent that `llms.txt` exists or that a markdown version is available. Agents that send `Accept: text/markdown` already get markdown, but agents that fetch HTML have no signal to try the markdown path. ## Solution - **HTML:** add a visually hidden directive as the first child of `<body>` in the root layout, so it comes before the navigation on every guide and reference page. It links to `https://supabase.com/docs/llms.txt` and says guide pages have a markdown version at the same path with `.md` appended, before any query string or fragment. It's `sr-only` and `aria-hidden`, and the link has `tabindex="-1"`. - **Crawler HTML:** bot requests for SDK reference pages are rewritten to `/api/crawlers`, which skips the root layout. The same directive goes before its `<nav>`. - **Markdown:** add a sentence linking `llms.txt` to the "Note for AI agents" blockquote in the guides markdown route. The agent feedback page skips the feedback text to avoid linking to itself, but it keeps the `llms.txt` line. - Add `LLMS_TXT_URL` and `LLMS_TXT_DIRECTIVE_HTML` to `common/markdown-affordance`, and reuse `LLMS_TXT_URL` in `proxy.ts`. The directive limits the `.md` claim to guides, because reference `.md` requests 404. It doesn't say `llms.txt` lists every page. The link targets `/docs/llms.txt`, the docs index that AFDocs scores for the `/docs` base URL. #53968 makes it a real file. Until that merges, `/docs/llms.txt` 308-redirects to the site-wide `/llms.txt`, so the link works in either merge order. ## Manual testing 1. Open a Vercel preview guide page and view source. Confirm the `llms.txt` directive comes before the navigation markup. 2. Open a reference page and confirm the same. 3. Confirm the directive isn't visible and isn't tabbable. 4. Request a reference section page with a bot user agent, such as `curl -A Googlebot`, and confirm the directive comes before `<nav>`. 5. Request a guide with `.md` appended and confirm the opening blockquote links `llms.txt`. 6. Request `/docs/guides/ai-tools/agent-feedback.md` and confirm the opening blockquote links `llms.txt`. 7. Run AFDocs against the preview and confirm `llms-txt-directive-html` and `llms-txt-directive-md` pass.
93 lines
3.0 KiB
TypeScript
93 lines
3.0 KiB
TypeScript
import 'ui-patterns/ShimmeringLoader/index.css'
|
|
import '../styles/globals.css'
|
|
import '../styles/prism-okaidia.css'
|
|
|
|
import { GlobalProviders } from '~/features/app.providers'
|
|
import { IaNavRouteProvider } from '~/features/IaNav'
|
|
import { IA_NAV_CACHE_SCRIPT } from '~/features/IaNav/constants'
|
|
import { DOCS_CONTENT_CONTAINER_ID } from '~/features/ui/helpers.constants'
|
|
import { TopNavSkeleton } from '~/layouts/MainSkeleton'
|
|
import { BASE_PATH, IS_PRODUCTION } from '~/lib/constants'
|
|
import { getCustomContent } from '~/lib/custom-content/getCustomContent'
|
|
import { TelemetryTagManager } from 'common'
|
|
import { SIGNED_IN_HINT_SCRIPT } from 'common/gotrue'
|
|
import { LLMS_TXT_DIRECTIVE_HTML } from 'common/markdown-affordance'
|
|
import { genFaviconData } from 'common/MetaFavicons/app-router'
|
|
import type { Metadata, Viewport } from 'next'
|
|
import { SkipToContent } from 'ui-patterns/SkipToContent'
|
|
|
|
import { inter, manrope } from '@/fonts'
|
|
|
|
const { metadataApplicationName, metadataTitle } = getCustomContent([
|
|
'metadata:application_name',
|
|
'metadata:title',
|
|
])
|
|
|
|
const FAVICON_ROUTE = process.env.NODE_ENV === 'development' ? '/favicon/local' : '/favicon'
|
|
|
|
const metadata: Metadata = {
|
|
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'),
|
|
icons: genFaviconData(BASE_PATH, FAVICON_ROUTE),
|
|
manifest: `${BASE_PATH}${FAVICON_ROUTE}/manifest.json`,
|
|
robots: {
|
|
index: IS_PRODUCTION,
|
|
follow: IS_PRODUCTION,
|
|
},
|
|
openGraph: {
|
|
type: 'article',
|
|
authors: 'Supabase',
|
|
url: `${BASE_PATH}`,
|
|
images: `${BASE_PATH}/img/supabase-og-image.png`,
|
|
publishedTime: new Date().toISOString(),
|
|
modifiedTime: new Date().toISOString(),
|
|
},
|
|
twitter: {
|
|
card: 'summary_large_image',
|
|
site: '@supabase',
|
|
creator: '@supabase',
|
|
images: `${BASE_PATH}/img/supabase-og-image.png`,
|
|
},
|
|
}
|
|
|
|
const viewport: Viewport = {
|
|
themeColor: '#1E1E1E',
|
|
}
|
|
|
|
const RootLayout = ({ children }: { children: React.ReactNode }) => {
|
|
return (
|
|
<html
|
|
lang="en"
|
|
className={`${manrope.variable} ${inter.variable}`}
|
|
data-scroll-behavior="smooth"
|
|
suppressHydrationWarning
|
|
>
|
|
<head>
|
|
<script dangerouslySetInnerHTML={{ __html: IA_NAV_CACHE_SCRIPT }} />
|
|
<script dangerouslySetInnerHTML={{ __html: SIGNED_IN_HINT_SCRIPT }} />
|
|
</head>
|
|
<body>
|
|
{/* for agents that fetch HTML and never try the markdown path */}
|
|
<div
|
|
className="sr-only"
|
|
aria-hidden="true"
|
|
dangerouslySetInnerHTML={{ __html: LLMS_TXT_DIRECTIVE_HTML }}
|
|
/>
|
|
<SkipToContent href={`#${DOCS_CONTENT_CONTAINER_ID}`} />
|
|
<TelemetryTagManager />
|
|
<GlobalProviders>
|
|
<IaNavRouteProvider>
|
|
<TopNavSkeleton>{children}</TopNavSkeleton>
|
|
</IaNavRouteProvider>
|
|
</GlobalProviders>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|
|
export { metadata, viewport }
|
|
export default RootLayout
|