From 197bf351ee636823cf50ed1f53266e24bb4dbf6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=80=89=E5=84=AA=E6=82=9F?= Date: Sun, 13 Sep 2020 18:05:56 +0900 Subject: [PATCH] fix: fix logic to correspond with config change --- src/node/server.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/node/server.ts b/src/node/server.ts index 644d041a..1b3f7c2d 100644 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -145,9 +145,14 @@ function getNextAndPrev(themeConfig: any, pagePath: string) { if (!sidebarItem.children) { return } - sidebarItem.children.forEach((candidate: any) => { - candidates.push(candidate) - }) + sidebarItem.children.forEach( + (candidate: { text: string; link: string }) => { + candidates.push({ + text: candidate.text, + link: convertToAbsolutePath(candidate.link) + }) + } + ) }) }) @@ -166,6 +171,13 @@ function getNextAndPrev(themeConfig: any, pagePath: string) { } } +function convertToAbsolutePath(path: string) { + if (!path.startsWith('/')) { + return `/${path}` + } + return path +} + export async function createServer(options: ServerConfig = {}) { const config = await resolveConfig(options.root)