From 29d01f76eca8cf3f7dfd18a47d19356f3a4be946 Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Wed, 27 Nov 2024 13:41:18 +0300 Subject: [PATCH] fix: Fix leading page urls for static build --- src/resolvers/md2html.ts | 2 +- src/utils/toc.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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';