From cef8321fa8fd43049520c170f0c22a75585befa6 Mon Sep 17 00:00:00 2001 From: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> Date: Sun, 2 Aug 2026 18:11:52 +0900 Subject: [PATCH] =?UTF-8?q?copilot=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/markdown/term.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/markdown/term.tsx b/app/markdown/term.tsx index 1550dac..ebf1e3b 100644 --- a/app/markdown/term.tsx +++ b/app/markdown/term.tsx @@ -108,8 +108,8 @@ export default function Term(props: JSX.IntrinsicElements["q"] & ExtraProps) { ); // ./1, ./1-foo, ./next, ./prev →同じ言語のドキュメントへのリンクで、「第n章」 - const pageIndexMatch = termText.match(/^.\/(\d+)$/); - const pageSlugMatch = termText.match(/^.\/([0-9a-zA-Z_-]+)$/); + const pageIndexMatch = termText.match(/^\.\/(\d+)$/); + const pageSlugMatch = termText.match(/^\.\/([0-9a-zA-Z_-]+)$/); if ( pageIndexMatch && langEntry && @@ -125,12 +125,13 @@ export default function Term(props: JSX.IntrinsicElements["q"] & ExtraProps) { langEntry.pages.find((p) => p.slug === pageSlugMatch[1])! ); } - const currentPageIndex = langEntry?.pages.findIndex((p) => p.slug === page); + const currentPageIndex = + langEntry?.pages.findIndex((p) => p.slug === page) ?? -1; if ( pageSlugMatch && langEntry && pageSlugMatch[1] === "prev" && - currentPageIndex !== undefined + currentPageIndex > 0 ) { // ./prev → 前のページ return internalLink(langEntry.pages[currentPageIndex - 1]); @@ -139,7 +140,8 @@ export default function Term(props: JSX.IntrinsicElements["q"] & ExtraProps) { pageSlugMatch && langEntry && pageSlugMatch[1] === "next" && - currentPageIndex !== undefined + currentPageIndex >= 0 && + currentPageIndex < langEntry.pages.length - 1 ) { // ./next → 次のページ return internalLink(langEntry.pages[currentPageIndex + 1]);