diff --git a/docs-site/docusaurus.config.ts b/docs-site/docusaurus.config.ts index 125c73e45f..91f8b32c06 100644 --- a/docs-site/docusaurus.config.ts +++ b/docs-site/docusaurus.config.ts @@ -31,6 +31,12 @@ const versions: string[] = rawVersions const lastVersion = versions[0] const hasVersions = lastVersion !== undefined +// Building every minor's full doc set on every release OOMs — cap the live site +// to the most recent minors. Older minors' markdown still lives in the GitHub repo and +// is served, unversioned, from the corresponding tag. +const MAX_BUILT_VERSIONS = 5 +const builtVersions = versions.slice(0, MAX_BUILT_VERSIONS) + const config: Config = { title: 'Gusto Embedded', tagline: 'Embedded Payroll React SDK Documentation', @@ -206,8 +212,9 @@ const config: Config = { ...(hasVersions && { lastVersion, includeCurrentVersion: false, + onlyIncludeVersions: builtVersions, versions: Object.fromEntries( - versions.map(version => [version, { banner: 'none' as const, badge: false }]), + builtVersions.map(version => [version, { banner: 'none' as const, badge: false }]), ), }), }, @@ -216,9 +223,9 @@ const config: Config = { // robots.txt blocks crawlers from fetching older-minor snapshots; keep // them out of the sitemap too, so it advertises only the canonical, // unprefixed /docs/ (the latest minor, driven by lastVersion). - // versions[0] is that latest minor served unprefixed, so slice(1) drops - // just the /docs// snapshots — no maintenance as new minors land. - ignorePatterns: hasVersions ? versions.slice(1).map(v => `/docs/${v}/**`) : [], + // builtVersions[0] is that latest minor served unprefixed, so slice(1) + // drops just the /docs// snapshots — no maintenance as new minors land. + ignorePatterns: hasVersions ? builtVersions.slice(1).map(v => `/docs/${v}/**`) : [], changefreq: 'weekly', priority: 0.5, }, diff --git a/docs-site/src/theme/NotFound/Content/index.tsx b/docs-site/src/theme/NotFound/Content/index.tsx index 2ba3141aa8..34b4ae8d8f 100644 --- a/docs-site/src/theme/NotFound/Content/index.tsx +++ b/docs-site/src/theme/NotFound/Content/index.tsx @@ -1,11 +1,19 @@ import Link from '@docusaurus/Link' +import { useLocation } from '@docusaurus/router' import useBaseUrl from '@docusaurus/useBaseUrl' import Heading from '@theme/Heading' import type { ReactNode } from 'react' import styles from './styles.module.css' +// Only the most recent minors are built into the live site (SDK-1344); older +// /docs// paths 404 here. Point readers at the git tag with the same +// content instead of leaving them stranded. +const OLD_VERSION_PATH = /^\/docs\/(\d+\.\d+)\// + export default function NotFoundContent(): ReactNode { const homeUrl = useBaseUrl('/') + const { pathname } = useLocation() + const oldVersionMatch = OLD_VERSION_PATH.exec(pathname) return (
@@ -16,6 +24,18 @@ export default function NotFoundContent(): ReactNode {

The page you're looking for doesn't exist or has been moved.

+ {oldVersionMatch && ( +

+ Looking for SDK {oldVersionMatch[1]} docs? Older versions aren't published on this + site, but the source is preserved at{' '} + + v{oldVersionMatch[1]}.0/docs + {' '} + in Gusto/embedded-react-sdk. +

+ )}
Go to Home