Skip to content

Commit

Permalink
fix: file group
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn committed Dec 9, 2024
1 parent ab6dd7e commit 6a9e1d5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/next/scripts/generate-docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ function transformAbsoluteUrl(content, filePath) {
return content.replace(
/\]\(([^)]+)\.mdx([^)]*)\)/g,
(match, slug, anchor) => {
const slugParts = slug.replace(/\/\.\.\//g, "").split("/");
if (slugParts.length === 1 && group) slugParts.unshift(group);
const result = ["/docs/api", ...slugParts, anchor]
const slugParts = slug.split("/");
const fileName = slugParts[slugParts.length - 1];
const fileGroup = slugParts[slugParts.length - 2] ?? group;
const result = ["/docs/api", fileGroup, fileName, anchor]
.filter(Boolean)
.join("/");
return `](${result})`;
Expand Down

0 comments on commit 6a9e1d5

Please sign in to comment.