@@ -213,10 +213,14 @@ function buildNavTree(): NavItem[] {
213213 return tree ;
214214}
215215
216+ function toHtmllessPath ( pathWithHtml : string ) : string {
217+ return pathWithHtml . replace ( / \. h t m l $ / , '' ) ;
218+ }
219+
216220function generateNavHtml ( items : NavItem [ ] , rootPath : string , currentPath : string , level : number = 0 ) : string {
217221 return items . map ( item => {
218222 const hasChildren = item . children && item . children . length > 0 ;
219- const itemPath = rootPath + item . path ;
223+ const itemPath = rootPath + toHtmllessPath ( item . path ) ;
220224 const isActive = currentPath === item . path ;
221225 const isParentOfActive = hasChildren && item . children ! . some ( child =>
222226 currentPath === child . path ||
@@ -270,12 +274,12 @@ function generatePrevNextHtml(prev: NavItem | null, next: NavItem | null, rootPa
270274
271275 let html = '<nav class="page-nav">' ;
272276 if ( prev ) {
273- html += `<a href="${ rootPath } ${ prev . path } " class="page-nav-link prev"><span class="page-nav-label">← 前へ</span><span class="page-nav-title">${ prev . title } </span></a>` ;
277+ html += `<a href="${ rootPath } ${ toHtmllessPath ( prev . path ) } " class="page-nav-link prev"><span class="page-nav-label">← 前へ</span><span class="page-nav-title">${ prev . title } </span></a>` ;
274278 } else {
275279 html += '<div></div>' ;
276280 }
277281 if ( next ) {
278- html += `<a href="${ rootPath } ${ next . path } " class="page-nav-link next"><span class="page-nav-label">次へ →</span><span class="page-nav-title">${ next . title } </span></a>` ;
282+ html += `<a href="${ rootPath } ${ toHtmllessPath ( next . path ) } " class="page-nav-link next"><span class="page-nav-label">次へ →</span><span class="page-nav-title">${ next . title } </span></a>` ;
279283 }
280284 html += '</nav>' ;
281285 return html ;
@@ -384,7 +388,7 @@ const template = (title: string, content: string, nav: string, rootPath: string,
384388<body>
385389 <nav class="sidebar">
386390 <div class="nav-header">
387- <a href="${ rootPath } index.html " class="nav-title">📘 たびたび Docs</a>
391+ <a href="${ rootPath } index" class="nav-title">📘 たびたび Docs</a>
388392 <div style="position: relative;">
389393 <input type="text" id="search-input" class="search-box" placeholder="検索...">
390394 <div id="search-results"></div>
@@ -433,7 +437,7 @@ const template = (title: string, content: string, nav: string, rootPath: string,
433437
434438 if (results.length > 0) {
435439 resultsContainer.innerHTML = results.map(item => \`
436- <a href="${ rootPath } \${item.id}.html " class="search-result-item">
440+ <a href="${ rootPath } \${item.id}" class="search-result-item">
437441 <div class="search-result-title">\${item.title}</div>
438442 <div class="search-result-preview">\${item.content.substring(0, 50)}...</div>
439443 </a>
@@ -482,7 +486,7 @@ const flatNav = flattenNavItems(navTree);
482486 const { prev, next } = getPrevNext ( navTree , currentPath ) ;
483487 const pageNavHtml = generatePrevNextHtml ( prev , next , rootPath ) ;
484488 const htmlContent = await marked ( content ) ;
485- const processedContent = htmlContent . replace ( / h r e f = " ( [ ^ " ] + ) \. m d " / g, 'href="$1.html "' ) ;
489+ const processedContent = htmlContent . replace ( / h r e f = " ( [ ^ " ] + ) \. m d " / g, 'href="$1"' ) ;
486490
487491 const finalHtml = template ( title , processedContent , navHtml , rootPath , pageNavHtml ) ;
488492
0 commit comments