Skip to content

Commit

Permalink
fix: Fix leading page urls for static build
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 27, 2024
1 parent 4ca82ad commit 29d01f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resolvers/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function getHref(root: string, path: string, href: string) {
href = href.replace(/\.(md|ya?ml)$/gi, '.html');
} else if (!/.+\.\w+$/gi.test(href)) {
// TODO: isFileExists index.md or index.yaml
href = href + '/index.html';
href = href + (href.endsWith('/') ? '' : '/') + 'index.html';
}

return href;
Expand Down
4 changes: 4 additions & 0 deletions src/utils/toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function transformToc(toc: YfmToc, tocDir: string) {
return href;
}

if (href.endsWith('/')) {
href += 'index.yaml';
}

const fileExtension: string = extname(href);
const filename: string = basename(href, fileExtension) + '.html';

Expand Down

0 comments on commit 29d01f7

Please sign in to comment.