Files
3x-ui-web-src/docs/scripts/gen-openapi.ts
T
Sanaei f727d04f65
CI / go-test (push) Canceled after 0s
CI / postgres-durable-first (push) Canceled after 0s
CI / codegen (push) Canceled after 0s
CI / govulncheck (push) Canceled after 0s
CI / race (push) Canceled after 0s
CI / fuzz-smoke (push) Canceled after 0s
CI / golangci (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CodeQL Advanced / Analyze (go) (push) Canceled after 0s
CodeQL Advanced / Analyze (actions) (push) Canceled after 0s
CodeQL Advanced / Analyze (javascript-typescript) (push) Canceled after 0s
Docs CI / build (push) Canceled after 0s
Docs Deploy (GitHub Pages) / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-latest) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-latest) (push) Canceled after 0s
Docs Deploy (GitHub Pages) / deploy (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
v3.7.0
2026-08-24 15:07:15 +02:00

33 lines
1.1 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { basename } from 'node:path';
import { generateFiles } from 'fumadocs-openapi';
import { openapi } from '../lib/openapi.ts';
// Map a slugified tag name back to its clean display name, so generated page
// titles read "API Tokens" instead of the auto-split "A P I Tokens".
const spec = JSON.parse(readFileSync('./public/openapi.json', 'utf8')) as {
tags?: { name: string }[];
};
const titleBySlug = new Map(
(spec.tags ?? []).map((t) => [t.name.toLowerCase().replace(/\s+/g, '-'), t.name]),
);
// Generate one MDX page per tag into the English reference/api folder.
// Other locales fall back to English for the API reference.
await generateFiles({
input: openapi,
output: './content/docs/en/reference/api',
per: 'tag',
beforeWrite(files) {
for (const file of files) {
const slug = basename(file.path).replace(/\.mdx$/, '');
const title = titleBySlug.get(slug);
if (title) {
file.content = file.content.replace(/^title:.*$/m, `title: ${title}`);
}
}
},
});
console.log('Generated API reference pages.');