Skip to content

Commit d6e1969

Browse files
committed
fix(docs): carry the landing-page backlink into integration markdown
1 parent c14e419 commit d6e1969

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

‎apps/docs/app/[[...slug]]/page.tsx‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type React from 'react'
22
import { Children, cloneElement, isValidElement } from 'react'
3-
import { LANDING_SLUG_BY_DOCS_SLUG } from '@sim/deployment-config/integration-docs'
4-
import { INTEGRATION_METADATA } from '@sim/deployment-config/integration-metadata'
53
import { highlight } from 'fumadocs-core/highlight'
64
import { findNeighbour } from 'fumadocs-core/page-tree'
75
import type { ApiPageProps } from 'fumadocs-openapi/ui'
@@ -19,28 +17,14 @@ import { APIExampleSelector } from '@/components/ui/api-example-selector'
1917
import { CodeBlock } from '@/components/ui/code-block'
2018
import { Heading } from '@/components/ui/heading'
2119
import { ResponseSection } from '@/components/ui/response-section'
20+
import { getIntegrationLandingPage, INTEGRATION_LANDING_LABEL } from '@/lib/integration-landing'
2221
import { getApiSpecContent, getAuthenticatedCodeSamples, openapi } from '@/lib/openapi'
2322
import { simShikiOptions } from '@/lib/shiki-theme'
2423
import { type PageData, source } from '@/lib/source'
25-
import { DOCS_BASE_URL, SIM_SITE_URL } from '@/lib/urls'
24+
import { DOCS_BASE_URL } from '@/lib/urls'
2625

2726
const BASE_URL = DOCS_BASE_URL
2827

29-
const INTEGRATION_NAME_BY_LANDING_SLUG = new Map(
30-
INTEGRATION_METADATA.map((integration) => [integration.slug, integration.name])
31-
)
32-
33-
/** The landing page a docs integration page (`/integrations/<docs slug>`) links to, if any. */
34-
function getIntegrationLandingPage(slug: string[] | undefined) {
35-
if (slug?.length !== 2 || slug[0] !== 'integrations') return undefined
36-
const landingSlug = LANDING_SLUG_BY_DOCS_SLUG.get(slug[1])
37-
if (!landingSlug) return undefined
38-
return {
39-
name: INTEGRATION_NAME_BY_LANDING_SLUG.get(landingSlug) ?? landingSlug,
40-
url: `${SIM_SITE_URL}/integrations/${landingSlug}`,
41-
}
42-
}
43-
4428
/**
4529
* Most pages close with a `## Next` / `## Next steps` grid of onward links.
4630
* That heading is navigation, not content, so it is kept out of the table of
@@ -286,10 +270,8 @@ export default async function Page(props: { params: Promise<{ slug?: string[] }>
286270
<DocsBody>
287271
{integrationLandingPage && (
288272
<p>
289-
Use cases and templates:{' '}
290-
<a href={integrationLandingPage.url}>
291-
{integrationLandingPage.name} integration for AI agents
292-
</a>
273+
{INTEGRATION_LANDING_LABEL}{' '}
274+
<a href={integrationLandingPage.url}>{integrationLandingPage.title}</a>
293275
</p>
294276
)}
295277
<MDX
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { LANDING_SLUG_BY_DOCS_SLUG } from '@sim/deployment-config/integration-docs'
2+
import { INTEGRATION_METADATA } from '@sim/deployment-config/integration-metadata'
3+
import { SIM_SITE_URL } from '@/lib/urls'
4+
5+
/** Lead-in for the docs page's link to its landing page, shared by the HTML and markdown forms. */
6+
export const INTEGRATION_LANDING_LABEL = 'Use cases and templates:'
7+
8+
const INTEGRATION_NAME_BY_LANDING_SLUG = new Map(
9+
INTEGRATION_METADATA.map((integration) => [integration.slug, integration.name])
10+
)
11+
12+
/** The landing page a docs integration page (`/integrations/<docs slug>`) links to, if any. */
13+
export function getIntegrationLandingPage(slugs: readonly string[] | undefined) {
14+
if (slugs?.length !== 2 || slugs[0] !== 'integrations') return undefined
15+
const landingSlug = LANDING_SLUG_BY_DOCS_SLUG.get(slugs[1])
16+
if (!landingSlug) return undefined
17+
const name = INTEGRATION_NAME_BY_LANDING_SLUG.get(landingSlug) ?? landingSlug
18+
return {
19+
title: `${name} integration for AI agents`,
20+
url: `${SIM_SITE_URL}/integrations/${landingSlug}`,
21+
}
22+
}

‎apps/docs/lib/llms.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { InferPageType } from 'fumadocs-core/source'
22
import type { ApiPageProps } from 'fumadocs-openapi/ui'
3+
import { getIntegrationLandingPage, INTEGRATION_LANDING_LABEL } from '@/lib/integration-landing'
34
import { getApiSpecContent } from '@/lib/openapi'
45
import type { PageData, source } from '@/lib/source'
56

@@ -55,7 +56,11 @@ export async function getLLMText(page: InferPageType<typeof source>) {
5556

5657
if (typeof data.getText !== 'function') return ''
5758
const processed = await data.getText('processed')
59+
const landingPage = getIntegrationLandingPage(page.slugs)
60+
const landingLink = landingPage
61+
? `${INTEGRATION_LANDING_LABEL} [${landingPage.title}](${landingPage.url})\n\n`
62+
: ''
5863
return `${heading}
5964
60-
${compactTables(processed)}`
65+
${landingLink}${compactTables(processed)}`
6166
}

0 commit comments

Comments
 (0)