Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs-site/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 }]),
),
}),
},
Expand All @@ -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/<page> (the latest minor, driven by lastVersion).
// versions[0] is that latest minor served unprefixed, so slice(1) drops
// just the /docs/<X.Y>/ 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/<X.Y>/ snapshots — no maintenance as new minors land.
ignorePatterns: hasVersions ? builtVersions.slice(1).map(v => `/docs/${v}/**`) : [],
changefreq: 'weekly',
priority: 0.5,
},
Expand Down
20 changes: 20 additions & 0 deletions docs-site/src/theme/NotFound/Content/index.tsx
Original file line number Diff line number Diff line change
@@ -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/<X.Y>/ 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 (
<div className={styles.root}>
Expand All @@ -16,6 +24,18 @@ export default function NotFoundContent(): ReactNode {
<p className={styles.subtitle}>
The page you&apos;re looking for doesn&apos;t exist or has been moved.
</p>
{oldVersionMatch && (
<p className={styles.subtitle}>
Looking for SDK {oldVersionMatch[1]} docs? Older versions aren&apos;t published on this
site, but the source is preserved at{' '}
<a
href={`https://github.com/Gusto/embedded-react-sdk/tree/v${oldVersionMatch[1]}.0/docs`}
>
v{oldVersionMatch[1]}.0/docs
</a>{' '}
in Gusto/embedded-react-sdk.
</p>
)}
<div className={styles.links}>
<Link to={homeUrl} className={styles.homeLink}>
Go to Home
Expand Down
Loading