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
21 changes: 17 additions & 4 deletions apps/docs/app/[lang]/[[...slug]]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,6 @@ import { notFound } from 'next/navigation'
import { PageFooter } from '@/components/docs-layout/page-footer'
import { PageNavigationArrows } from '@/components/docs-layout/page-navigation-arrows'
import { LLMCopyButton } from '@/components/page-actions'
import { PageTypeBadge } from '@/components/page-type-badge'
import { StructuredData } from '@/components/structured-data'
import { CodeBlock } from '@/components/ui/code-block'
import { Heading } from '@/components/ui/heading'
Expand All@@ -23,6 +22,21 @@ import { DOCS_BASE_URL } from '@/lib/urls'
const SUPPORTED_LANGUAGES: Set<string> = new Set(i18n.languages)
const BASE_URL = DOCS_BASE_URL

/**
* Most pages close with a `## Next` / `## Next steps` grid of onward links.
* That heading is navigation, not content, so it is kept out of the table of
* contents — the ToC should say what the page covers, not where to go after it.
* The heading itself still renders above the cards.
*
* Matched on the slug rather than the rendered title because a ToC title is a
* `ReactNode`; the trailing group tolerates the slugger's dedupe suffix.
*/
const ONWARD_NAV_SLUG = /^#next(-steps)?(-\d+)?$/i

function isContentHeading(item: { url: string }): boolean {
return !ONWARD_NAV_SLUG.test(item.url)
}

const OG_LOCALE_MAP: Record<string, string> = {
en: 'en_US',
es: 'es_ES',
Expand DownExpand Up@@ -171,7 +185,7 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
breadcrumb={breadcrumbs}
/>
<DocsPage
toc={data.toc}
toc={data.toc.filter(isContentHeading)}
breadcrumb={{
enabled: false,
}}
Expand DownExpand Up@@ -218,7 +232,7 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
breadcrumb={breadcrumbs}
/>
<DocsPage
toc={data.toc}
toc={data.toc.filter(isContentHeading)}
full={data.full || isAcademy}
breadcrumb={{
enabled: false,
Expand All@@ -244,7 +258,6 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
</div>
<PageNavigationArrows previous={neighbours?.previous} next={neighbours?.next} />
</div>
{data.pageType && <PageTypeBadge type={data.pageType} className='mb-3' />}
<DocsTitle className='mb-2'>{data.title}</DocsTitle>
</div>
<DocsBody>
Expand Down
Loading
Loading