Repository navigation
improvement(seo): fix soft 404s, per-integration freshness, and docs markdown for AI crawlers #9006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7200e21
improvement(seo): fix soft 404s, per-integration freshness, and docs …
waleedlatif1 c45a317
test(seo): crawl the production build for landing SEO regressions
waleedlatif1 d129483
chore(landing): remove the post and author loading skeletons the slug…
waleedlatif1 c14e419
fix(seo): resolve docs slugs through the catalog, keep API pages nego…
waleedlatif1 d6e1969
fix(docs): carry the landing-page backlink into integration markdown
waleedlatif1 5ec12e2
test(seo): match the visible date attribute case-insensitively
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { LANDING_SLUG_BY_DOCS_SLUG } from '@sim/deployment-config/integration-docs' | ||
| import { INTEGRATION_METADATA } from '@sim/deployment-config/integration-metadata' | ||
| import { SIM_SITE_URL } from '@/lib/urls' | ||
|
|
||
| /** Lead-in for the docs page's link to its landing page, shared by the HTML and markdown forms. */ | ||
| export const INTEGRATION_LANDING_LABEL = 'Use cases and templates:' | ||
|
|
||
| const INTEGRATION_NAME_BY_LANDING_SLUG = new Map( | ||
| INTEGRATION_METADATA.map((integration) => [integration.slug, integration.name]) | ||
| ) | ||
|
|
||
| /** The landing page a docs integration page (`/integrations/<docs slug>`) links to, if any. */ | ||
| export function getIntegrationLandingPage(slugs: readonly string[] | undefined) { | ||
| if (slugs?.length !== 2 || slugs[0] !== 'integrations') return undefined | ||
| const landingSlug = LANDING_SLUG_BY_DOCS_SLUG.get(slugs[1]) | ||
| if (!landingSlug) return undefined | ||
| const name = INTEGRATION_NAME_BY_LANDING_SLUG.get(landingSlug) ?? landingSlug | ||
| return { | ||
| title: `${name} integration for AI agents`, | ||
| url: `${SIM_SITE_URL}/integrations/${landingSlug}`, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,66 @@ | ||
| import type { InferPageType } from 'fumadocs-core/source' | ||
| import type { ApiPageProps } from 'fumadocs-openapi/ui' | ||
| import { getIntegrationLandingPage, INTEGRATION_LANDING_LABEL } from '@/lib/integration-landing' | ||
| import { getApiSpecContent } from '@/lib/openapi' | ||
| import type { PageData, source } from '@/lib/source' | ||
|
|
||
| const TABLE_ROW = /^\|.*\|$/ | ||
| const TABLE_DELIMITER_CELL = /^\s*(:?)-+(:?)\s*$/ | ||
| const UNESCAPED_PIPE = /(?<!\\)\|/ | ||
|
|
||
| /** | ||
| * The processed-markdown serializer pads every table cell to its column's widest cell, so one long | ||
| * enum (a parameter listing every timezone) pads every row of its table and roughly doubles the | ||
| * integration reference. Drop that trailing padding; a cell's own leading indentation (the `↳` | ||
| * nesting in output tables) and inline code are kept, and the tables stay valid GFM. | ||
| */ | ||
| function compactTables(markdown: string): string { | ||
| let inFence = false | ||
| return markdown | ||
| .split('\n') | ||
| .map((line) => { | ||
| if (line.startsWith('```')) inFence = !inFence | ||
| if (inFence || !TABLE_ROW.test(line)) return line | ||
| const cells = line.slice(1, -1).split(UNESCAPED_PIPE) | ||
| if (cells.every((cell) => TABLE_DELIMITER_CELL.test(cell))) { | ||
| return `|${cells.map((cell) => cell.replace(TABLE_DELIMITER_CELL, ' $1---$2 ')).join('|')}|` | ||
| } | ||
| return `|${cells.map((cell) => ` ${cell.replace(/^ /, '').trimEnd()} `).join('|')}|` | ||
| }) | ||
| .join('\n') | ||
| } | ||
|
|
||
| type LLMPageData = PageData & { getAPIPageProps?: () => ApiPageProps } | ||
|
|
||
| /** | ||
| * OpenAPI operation pages are virtual: no MDX body, and a fully resolved request/response schema | ||
| * (~40 KB each, mostly shared components) that is useful per page but would double `llms-full.txt`. | ||
| */ | ||
| export function isApiOperationPage(page: InferPageType<typeof source>): boolean { | ||
| return typeof (page.data as unknown as LLMPageData).getAPIPageProps === 'function' | ||
| } | ||
|
|
||
| export async function getLLMText(page: InferPageType<typeof source>) { | ||
| const data = page.data as unknown as PageData | ||
| const data = page.data as unknown as LLMPageData | ||
| const heading = `# ${data.title} (${page.url})` | ||
|
|
||
| // Operation pages get the same markdown the page's "Copy page" action builds. | ||
| if (typeof data.getAPIPageProps === 'function') { | ||
| const spec = getApiSpecContent( | ||
| data.title, | ||
| data.description, | ||
| data.getAPIPageProps().operations ?? [] | ||
| ) | ||
| return spec.replace(/^# .*$/m, heading) | ||
| } | ||
|
|
||
| if (typeof data.getText !== 'function') return '' | ||
| const processed = await data.getText('processed') | ||
| return `# ${data.title} (${page.url}) | ||
| const landingPage = getIntegrationLandingPage(page.slugs) | ||
| const landingLink = landingPage | ||
| ? `${INTEGRATION_LANDING_LABEL} [${landingPage.title}](${landingPage.url})\n\n` | ||
| : '' | ||
| return `${heading} | ||
|
|
||
| ${processed}` | ||
| ${landingLink}${compactTables(processed)}` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.