Skip to content
Open
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: 20 additions & 1 deletion scripts/build-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ description: This is a simple test page
lastUpdated: ${initialCommitDate.toISOString()}
sdkScoped: "false"
canonical: /docs/simple-test
sourceFile: /docs/simple-test.mdx
---

# Simple Test Page
Expand Down Expand Up @@ -1664,6 +1665,7 @@ canonical: /docs/references/react/guide
availableSdks: react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/references/react/guide.mdx
---

# React Guide
Expand Down Expand Up @@ -1730,6 +1732,7 @@ canonical: /docs/guide
availableSdks: react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/guide.mdx
---

# React Guide
Expand Down Expand Up @@ -1791,6 +1794,7 @@ title: API Documentation
description: x
sdkScoped: "false"
canonical: /docs/api-doc
sourceFile: /docs/api-doc.mdx
---

# API Documentation
Expand Down Expand Up @@ -1859,6 +1863,7 @@ canonical: /docs/quickstarts/nextjs-pages-router
availableSdks: nextjs
notAvailableSdks: react
activeSdk: nextjs
sourceFile: /docs/quickstarts/nextjs-pages-router.mdx
---

# Next.js Quickstart (Pages Router)
Expand Down Expand Up @@ -3862,6 +3867,7 @@ canonical: /docs/doc-2
availableSdks: react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/doc-2.mdx
---

[Link to doc 1](/docs/doc-1)
Expand Down Expand Up @@ -4149,6 +4155,7 @@ title: Doc 2
description: x
sdkScoped: "false"
canonical: /docs/doc-2
sourceFile: /docs/doc-2.mdx
---

<Cards>
Expand Down Expand Up @@ -4229,6 +4236,7 @@ canonical: /docs/:sdk:/guide-2
availableSdks: react,nextjs
notAvailableSdks: ""
activeSdk: nextjs
sourceFile: /docs/guide-2.nextjs.mdx
---

<SDKLink href="/docs/guide-1" sdks={["react"]}>Link</SDKLink>
Expand Down Expand Up @@ -6445,6 +6453,7 @@ canonical: /docs/:sdk:/doc-2
availableSdks: expo,nextjs
notAvailableSdks: react
activeSdk: expo
sourceFile: /docs/doc-2.mdx
---

<SDKLink href="/docs/reference/react/doc-1" sdks={["react"]}>Doc 1</SDKLink>
Expand Down Expand Up @@ -6590,6 +6599,7 @@ title: API Documentation
description: Generated API docs
sdkScoped: "false"
canonical: /docs/api-doc
sourceFile: /docs/api-doc.mdx
---

# API Documentation
Expand Down Expand Up @@ -6659,6 +6669,7 @@ canonical: /docs/:sdk:/api-doc
availableSdks: nextjs,remix,react
notAvailableSdks: ""
activeSdk: nextjs
sourceFile: /docs/api-doc.mdx
---

Documentation specific to Next.js and Remix
Expand All @@ -6673,6 +6684,7 @@ canonical: /docs/:sdk:/api-doc
availableSdks: nextjs,remix,react
notAvailableSdks: ""
activeSdk: remix
sourceFile: /docs/api-doc.mdx
---

Documentation specific to Next.js and Remix
Expand All @@ -6687,6 +6699,7 @@ sdk: nextjs, remix, react
availableSdks: nextjs,remix,react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/api-doc.react.mdx
---

Documentation specific to React.js
Expand Down Expand Up @@ -6770,6 +6783,7 @@ canonical: /docs/:sdk:/test
availableSdks: react,nextjs
notAvailableSdks: ""
activeSdk: nextjs
sourceFile: /docs/test.nextjs.mdx
---

Documentation specific to Next.js
Expand All @@ -6783,6 +6797,7 @@ canonical: /docs/:sdk:/test
availableSdks: react,nextjs
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/test.mdx
---

Documentation specific to React
Expand Down Expand Up @@ -6864,6 +6879,7 @@ title: Overview
description: x
sdkScoped: "false"
canonical: /docs/overview
sourceFile: /docs/overview.mdx
---

<SDKLink href="/docs/:sdk:/api-doc" sdks={["nextjs","remix","react"]}>API Doc</SDKLink>
Expand Down Expand Up @@ -6932,6 +6948,7 @@ sdk: nextjs, remix, react
availableSdks: nextjs,remix,react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/api-doc.react.mdx
---

Documentation specific to React.js
Expand Down Expand Up @@ -6961,6 +6978,7 @@ sdk: nextjs, remix, react
availableSdks: nextjs,remix,react
notAvailableSdks: ""
activeSdk: react
sourceFile: /docs/api-doc.react.mdx
---

Updated Documentation specific to React.js
Expand Down Expand Up @@ -7159,14 +7177,15 @@ title: API Documentation
description: x
sdkScoped: "false"
canonical: /docs/api-doc
sourceFile: /docs/api-doc.mdx
---

<Tooltip><TooltipTrigger>Tooltip</TooltipTrigger><TooltipContent>React.js is a framework or a library idk</TooltipContent></Tooltip>
`)
})

test('Should validate links in tooltips', async () => {
const { tempDir, readFile } = await createTempFiles([
const { tempDir } = await createTempFiles([
{
path: './docs/manifest.json',
content: JSON.stringify({
Expand Down
19 changes: 13 additions & 6 deletions scripts/build-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ export async function build(config: BuildConfig, store: Store = createBlankStore
lastUpdated: (await getCommitDate(doc.file.fullFilePath))?.toISOString() ?? undefined,
sdkScoped: 'false',
canonical: doc.file.href,
sourceFile: `/docs/${doc.file.filePathInDocsFolder}`,
}),
)
.process(doc.vfile),
Expand Down Expand Up @@ -991,17 +992,22 @@ ${yaml.stringify({
if (doc.file.filePathInDocsFolder.endsWith(`.${targetSdk}.mdx`)) return null

// if the doc has distinct version, we want to use those instead of the "generic" sdk scoped version
const fileContent = (() => {
const { fileContent, sourceFile } = (() => {
if (doc.distinctSDKVariants?.includes(targetSdk)) {
const distinctSDKVariant = docsMap.get(`${doc.file.href}.${targetSdk}`)

if (distinctSDKVariant === undefined) return doc.fileContent

return distinctSDKVariant.fileContent
if (distinctSDKVariant !== undefined) {
return {
fileContent: distinctSDKVariant.fileContent,
sourceFile: `/docs/${distinctSDKVariant.file.filePathInDocsFolder}`,
}
}
}
return {
fileContent: doc.fileContent,
sourceFile: `/docs/${doc.file.filePathInDocsFolder}`,
}
return doc.fileContent
})()

const sdks = [...(doc.sdk ?? []), ...(doc.distinctSDKVariants ?? [])]

const hrefSegments = doc.file.href.split('/')
Expand Down Expand Up @@ -1032,6 +1038,7 @@ ${yaml.stringify({
availableSdks: sdks?.join(','),
notAvailableSdks: config.validSdks.filter((sdk) => !sdks?.includes(sdk)).join(','),
activeSdk: targetSdk,
sourceFile: sourceFile,
}),
)
.process({
Expand Down