Closes DOCS-1753 ## Problem Guide pages already show a "Last updated" date (supabase/supabase#52421), but `sitemap.xml` has no `<lastmod>`, so crawlers get no recency signal. ## Solution - Guide entries in `sitemap.xml` now include `<lastmod>`. The date comes from the same `last_changed` table as the on-page date: the newest `last_updated` across a page's sections, written as an ISO 8601 timestamp. - The paginated `last_changed` read moved from `lib/last-changed.ts` into `lib/last-changed.utils.ts`. The new module has no `server-only` import, so the `tsx` sitemap script can share it. `getGuideLastUpdated` behaves the same, including its timeout, cooldown, and Sentry reporting. - When `NEXT_PUBLIC_SUPABASE_URL` or `SUPABASE_SECRET_KEY` is missing, or the read fails, the script logs a warning and writes the sitemap without `<lastmod>`. Local and preview builds still succeed. - `build:sitemap` in `apps/docs/turbo.jsonc` is now uncached and passes the two credentials through. The dates change nightly, outside the task's inputs, so a cache hit could otherwise restore stale dates. The task is cheap, and its dependencies stay cached. - Reference pages don't get `<lastmod>` because `last_changed` only tracks guides. - `sitemap.md` (marked TBD in the issue) is out of scope. ## Review instructions | Preview | Link | | --- | --- | | Docs sitemap | https://docs-git-claude-compassionate-dirac-ns0vjr-supabase.vercel.app/docs/sitemap.xml | | Docs app | https://docs-git-claude-compassionate-dirac-ns0vjr-supabase.vercel.app/docs | 1. Check the `build:sitemap` step in the Vercel build log. It should print `Total of N pages in sitemap (M with last-modified dates)`, where M is greater than 0. 2. In the preview deploy, open `/docs/sitemap.xml` and confirm that guide entries have `<lastmod>` values matching the "Last updated" date on those pages. 3. Optional local check: run `pnpm -F docs build:sitemap` without credentials. You should see the warning, and the sitemap should have no `<lastmod>` entries. Co-authored-by: Claude <noreply@anthropic.com>
7.3 KiB
Docs build pipeline
How apps/docs is built through the Turborepo task graph. There are no pnpm
pre/post lifecycle hooks: ordering lives in dependsOn in
apps/docs/turbo.jsonc.
Verify against the current apps/docs/turbo.jsonc and
apps/docs/package.json if behavior surprises you.
Verified at: 3089aa3f67 (2026-11-25).
Build flow
flowchart TB
subgraph turbo["Turborepo — apps/docs/turbo.jsonc"]
direction TB
WP["^build — workspace deps<br/>(common, ui, config, icons, …)"]
GQL["codegen:graphql"]
EX["codegen:examples<br/>copy ../../examples → apps/docs/examples"]
CR["codegen:references<br/>legacy + new (ensure, dart)<br/>→ features/docs/generated/**, content/reference/**"]
MD["build:markdown<br/>build:guides-markdown (after build:federated-content)<br/>+ build:reference-markdown"]
GZ["build:gz-archive"]
SM["build:sitemap"]
RD["redirects:generate"]
CR --> MD --> GZ
WP --> DOC["docs#build — next build"]
GQL --> DOC
EX --> DOC
CR --> DOC
MD --> DOC
GZ --> DOC
SM --> DOC
RD --> DOC
end
Commands
From the repo root:
- Full graph:
pnpm build→turbo run build(builds every package/app in dependency order). - Docs only:
pnpm build:docs→turbo run build --filter=docs.
"build:docs": "turbo run build --filter=docs"
What Turbo does
Root turbo.jsonc defines build with dependsOn: ["^build"], so
workspace dependencies of docs (e.g. common, ui, config, …) are
built before docs.
apps/docs/turbo.jsonc extends that and tightens the docs tasks:
buildalso depends oncodegen:graphql,codegen:examples,codegen:references,build:markdown,build:gz-archive,build:sitemapandredirects:generate.devdepends oncodegen:graphql,codegen:examplesandcodegen:references.typecheckdepends oncodegen:graphql,testoncodegen:examples,test:smoke/embeddingsoncodegen:references,synconcodegen:graphql, andingest:search_v2onbuild:guides-markdownandcodegen:references.codegen:referenceshas no script of its own: it groupscodegen:references:legacyandcodegen:references:new, and the latter depends oncodegen:references:new:ensureandcodegen:references:dart.build:markdownlikewise groupsbuild:guides-markdownandbuild:reference-markdown.- It lists env vars and
inputs/outputsthat affect caching for the docs app. Tasks that fetch remote content (build:federated-content,codegen:references:new:ensure) are uncached.build:sitemapis also uncached: it reads<lastmod>dates from thelast_changedtable, which the nightly last-changed workflow updates outside the task's inputs.
Pipeline Turbo orchestrates for docs: dependency packages → codegen → markdown / archive / sitemap / redirects → Next build.
The maybe-turbo wrapper
The docs package has no pnpm pre / post hooks. Scripts that have
prerequisites are wrapped with the maybe-turbo bin (packages/maybe-turbo),
for example:
"build": "maybe-turbo next build --webpack"
pnpm dev runs next dev (Turbopack). The production build runs
next build --webpack. A loader or bundler change must work in both.
next.config.mjs has a webpack block and a turbopack block.
Outside Turbo, pnpm build, pnpm dev, pnpm codegen:references,
pnpm ingest:search_v2 and friends re-invoke themselves as
turbo run <script> --filter=docs, so the prerequisites still run (now
cached by Turbo). Inside Turbo the wrapper runs the command directly.
Existing commands keep working unchanged. A wrapper with no command (such as
codegen:references or build:markdown) only groups its dependencies.
pnpm dev in apps/docs, pnpm dev --filter=docs and pnpm dev:docs from the
repo root run the same task graph. Before the wrapper, the root commands used
turbo.jsonc and package-level commands used prebuild/predev, so the same
pipeline was defined twice and could drift. Add new steps to turbo.jsonc
only. See packages/maybe-turbo/README.md for why scripts use the wrapper
instead of calling turbo directly.
Codegen scripts
codegen:graphql— generates GraphQL types from schema.codegen:examples— copiesexamples/from monorepo root intoapps/docs/examplesfor$CodeSampledirective resolution.codegen:references:legacy—features/docs/Reference.generated.script.ts(includes Management API: merge OpenAPI v1+v2 →api.latest.*JSON). Spec download/bundle lives inapps/docs/spec/Makefile(Redocly); seemanagement-api-reference.md.codegen:references:new—scripts/build-reference-content.ts(from TSDoc JSON underspec/reference/). Output lands incontent/reference/**. Itscodegen:references:new:ensure(download missing TypeDoc dumps) andcodegen:references:dartprerequisites run as turbo dependencies.build:guides-markdown— runsinternals/generate-guides-markdown.tsovercontent/guides/**/*.mdx. Producespublic/markdown/guides/**.md.build:reference-markdown— runsinternals/generate-reference-markdown.ts. Producespublic/markdown/reference/**.md.build:markdown— shorthand for guides + reference markdown.build:gz-archive— runsinternals/generate-gz-archive.ts. Producespublic/docs.tar.gz(tarball of allpublic/markdown/).
For how agents consume these outputs, see
llm-agent-surface.md.
Deploy vs CI
- Production build for the site is Vercel;
apps/docs/vercel.jsonsetsbuildCommandtopnpm build(the Turbo graph above). - GitHub Actions mostly run tests (
test:docs→ Turbo), lint, sync jobs, and smoke tests — not a separate full production build graph in the way Turbo does locally. Seeci-and-lint.md.
Local development
From apps/docs:
pnpm dev # http://localhost:3001/docs
devdepends on GraphQL and reference codegen plus example copy inturbo.jsonc, sopnpm devruns them first.- Community contributors: set
NEXT_PUBLIC_IS_PLATFORM=falsein.env. - Supabase employees:
pnpm run dev:secrets:pullfor internal env vars (AWS profile +scripts/getSecrets.js). - In dev mode, the app only builds routes upon request rather than pre-rendering — preview and production environments statically generate routes during build for speed.
Why this shape matters for changes
- Adding a new build step? See
adding-features.md"Reuse pipelines, don't fork them" and check if an existing turbo task inapps/docs/turbo.jsoncalready fits (add adependsOnentry rather than apre/posthook). - New env var? Add it to
apps/docs/turbo.jsonc'senvso Turbo doesn't cache stale. - Touching the markdown export? Read
app-map.md"The two pipelines" first — runtime and export share data, not code paths.
Related
app-map.md— directory layout and runtime / export split.ci-and-lint.md— GitHub Actions workflow surface.federated-docs.md— external content fetched during build.