diff --git a/src/resolvers/md2html.ts b/src/resolvers/md2html.ts index 0c9d572c..b221750f 100644 --- a/src/resolvers/md2html.ts +++ b/src/resolvers/md2html.ts @@ -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; diff --git a/src/utils/toc.ts b/src/utils/toc.ts index 2d33599e..9f903039 100644 --- a/src/utils/toc.ts +++ b/src/utils/toc.ts @@ -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';