Skip to content

Commit

Permalink
fix: better doc title generation (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
stigi authored Dec 19, 2024
1 parent e59c037 commit 1804bb1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ for (const file of docs) {
md.reIndentHeadings(ast, 1);
md.mapLinks(ast, rewriteHref);

const title = md.getTitle(ast);
md.insertFrontMatter(ast, { title });
let titleComponents = path.parse(file).name.split(".");
// Removing noisy namespaces
if (titleComponents.length > 1 && titleComponents[0] === "Components") {
titleComponents.shift();
}
if (titleComponents.length > 1 && titleComponents[0] === "Schemas") {
titleComponents.shift();
}
if (titleComponents.length > 1 && titleComponents[0] === "Operations") {
titleComponents.shift();
}
md.insertFrontMatter(ast, { title: titleComponents.join(".") });
md.removeFirstHeading(ast);

await md.write(ast, path.join(outdir, pascalToHyphenCase(file) + "x"));
Expand Down

0 comments on commit 1804bb1

Please sign in to comment.