Files
website/apps/docs/scripts/fix-api-paths.mjs
Mauricio Siu a85fb76a95 chore: update Node.js and pnpm versions in Dockerfiles and package.json
- Updated base image in Dockerfile.docs and Dockerfile.website to Node.js 24.4-alpine.
- Updated package manager version in package.json to pnpm 10.22.0.
- Adjusted Node.js engine requirement in package.json to ^24.4.0.
- Added new script to fix API path references in MDX files for documentation.
- Updated build command in apps/docs/package.json to include the new script.
2026-02-27 02:52:18 -06:00

28 lines
924 B
JavaScript

/**
* Normalizes OpenAPI path references in API docs MDX files.
* Converts dot notation (/tag.operation) to slash notation (/tag/operation)
* to match the OpenAPI schema paths.
*/
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const API_DOCS_DIR = join(process.cwd(), "content", "docs", "api");
let totalFixed = 0;
for (const name of readdirSync(API_DOCS_DIR)) {
if (!name.endsWith(".mdx")) continue;
const file = join(API_DOCS_DIR, name);
const content = readFileSync(file, "utf8");
const newContent = content.replace(/"path":"(\/[^"]+)"/g, (_, path) => {
if (path.includes(".")) {
totalFixed++;
return `"path":"${path.replace(/\./g, "/")}"`;
}
return `"path":"${path}"`;
});
if (newContent !== content) writeFileSync(file, newContent);
}
if (totalFixed > 0) {
console.log(`✓ Normalized ${totalFixed} API path(s) in MDX (dot → slash)`);
}