docs(misc): update getSchemaViewModel to return new API path rather than /nx-api/:plugin (#31561)

This PR updates pages like
`/technologies/typescript/api/executors/verdaccio`, such that the
backlink to the API index is correct. Even though we redirect `/nx-api`
pages, the Next.js pages router does not respect them and users see 404
instead.
This commit is contained in:
Jack Hsu 2025-06-12 12:28:47 -04:00 committed by GitHub
parent 5ac1c08d34
commit 51dced2469
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,7 @@ import {
} from '@nx/nx-dev/models-package';
import { ParsedUrlQuery } from 'querystring';
import { Errors, Example, generateJsonExampleFor } from './examples';
import { pkgToGeneratedApiDocs } from '@nx/nx-dev/models-document';
function getReferenceFromQuery(query: string): string {
return query.replace('root/', '#/');
@ -28,7 +29,7 @@ export interface SchemaViewModel {
schemaGithubUrl: string;
schemaMetadata: SchemaMetadata;
subReference: string;
type: 'executor' | 'generator';
type: 'executor' | 'generator' | 'migration';
}
export function getSchemaViewModel(
@ -37,11 +38,12 @@ export function getSchemaViewModel(
schema: SchemaMetadata
): SchemaViewModel | null {
if (!schema.schema) return null;
const packageUrl = pkgToGeneratedApiDocs[pkg.name].pagePath;
return {
schemaMetadata: schema,
packageName: pkg.packageName,
packageUrl: `/nx-api/${pkg.name}`,
packageUrl,
schemaGithubUrl: pkg.githubRoot + schema.path,
rootReference: '#',
subReference: