diff --git a/src/views/docs-view/server.ts b/src/views/docs-view/server.ts index db77ecfff7..257a7cd40f 100644 --- a/src/views/docs-view/server.ts +++ b/src/views/docs-view/server.ts @@ -166,6 +166,93 @@ export function getStaticGenerationFunctions< basePath: basePathForLoader, enabledVersionedDocs: true, navDataPrefix, + mdxContentHook: (mdxContent: string) => { + /** + * NOTE: this patches an unclear issue with upstream MDX content, + * which uses custom HTML tags that seem to get borked somewhere along + * the ETL pipeline, apparently before extraction as our database returns + * MDX with a bunch of `<a` strings rather than ` + * + * + * + * **`[-address | VAULT_ADDR] (string: 'https://127.0.0.1:8200')`** + * + * + * + * Some content about the global address variable here... + * ``` + * + * Authors could use auto-permalinked list items or headings to achieve + * a similar effect. To get specific, list items could provide a similar + * user experience: + * + * ```markdown + * ## Configure environment variables + * + * Some more content here, etc... + * + * - `[-address | VAULT_ADDR] (string: 'https://127.0.0.1:8200')` ((#global-address)) + * - Some content about the global address variable here... + * ``` + * + * Or headings might be more appropriate or preferable, depending + * on context: + * + * ```markdown + * ## Configure environment variables + * + * Some more content here, etc... + * + * ### `[-address | VAULT_ADDR] (string: 'https://127.0.0.1:8200')` ((#global-address)) + * + * Some content about the global address variable here... + */ + /** + * We only want to apply this fix to affected pages. Ideally, + * we'd be a little more targeted, including the page slug + * (so, `vault/docs/commands` rather than `vault/docs/**`), + * but for now, this seems to work. + */ + const affectedBasePaths = [['vault', 'docs']] + const isAffectedPage = affectedBasePaths.some(([product, basePath]) => { + return ( + product === productSlugForLoader && basePath === basePathForLoader + ) + }) + if (isAffectedPage) { + return mdxContent.replace(/<a/g, '