Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 4, 2025

The navigation sidebar was missing all appendices (付録A through 付録G), making it impossible to navigate to these important sections from the table of contents menu. This affected both desktop and mobile hamburger menu navigation.

Problem

The populateNavigation() function in website/js/app.js only recognized two markdown link formats:

  • Chapter headings with ### prefix
  • Direct chapter references with ## prefix

However, appendices use a different format in the table of contents:

- **[付録A 美しいソースコードのための七箇条](appendix-a.md)** - 詳細版・実践ガイド
- **[付録B 命名規則とコーディング規約例](appendix-b.md)** - 多言語対応

This format was not matched by existing regex patterns, causing all appendices to be excluded from navigation.

Solution

Added a new regex pattern to detect and parse appendix links:

// Match appendix links like - **[付録A 美しいソースコードのための七箇条](appendix-a.md)** - 詳細版・実践ガイド
const appendixMatch = line.match(/^\s*-\s*\*\*\[([^\]]+)\]\(([^)]+)\)\*\*/);
if (appendixMatch) {
    const title = appendixMatch[1];
    const filename = decodeURIComponent(appendixMatch[2]).replace('.md', '');
    navHtml += `<li><a href="#" onclick="loadPage('${filename}')">${title}</a></li>`;
}

This minimal 8-line addition preserves all existing functionality while adding support for appendix navigation.

Testing

✅ All appendices A-G now appear in navigation menu
✅ Clicking appendices correctly loads content
✅ Active state updates properly when navigating
✅ Mobile responsive design preserved
✅ Existing chapter navigation unaffected

Desktop View:
Desktop navigation showing all appendices

Mobile View:
Mobile navigation showing all appendices

Fixes #113.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: Fujiwo <3992360+Fujiwo@users.noreply.github.com>
Copilot AI changed the title [WIP] Bug Fix: index.html で表示される目次に付録も表示 Fix: Add appendices A-G to navigation menu for both desktop and mobile Sep 4, 2025
Copilot AI requested a review from Fujiwo September 4, 2025 05:17
Copilot finished work on behalf of Fujiwo September 4, 2025 05:17
@Fujiwo Fujiwo marked this pull request as ready for review September 4, 2025 05:32
Copilot AI review requested due to automatic review settings September 4, 2025 05:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a navigation issue where appendices A-G were missing from both desktop and mobile navigation menus. The fix adds a new regex pattern to detect appendix links in the table of contents markdown, enabling proper navigation to these important sections.

Key Changes

  • Added regex pattern to parse appendix links with bold formatting and descriptions
  • Extended navigation population logic to include appendices alongside existing chapters
  • Maintained backward compatibility with existing chapter navigation patterns

Comment on lines +128 to +135

// Match appendix links like - **[付録A 美しいソースコードのための七箇条](appendix-a.md)** - 詳細版・実践ガイド
const appendixMatch = line.match(/^\s*-\s*\*\*\[([^\]]+)\]\(([^)]+)\)\*\*/);
if (appendixMatch) {
const title = appendixMatch[1];
const filename = decodeURIComponent(appendixMatch[2]).replace('.md', '');
navHtml += `<li><a href="#" onclick="loadPage('${filename}')">${title}</a></li>`;
}
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The appendix handling logic duplicates the exact same title extraction and HTML generation pattern used for directChapterMatch above. Consider extracting this into a helper function to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
@Fujiwo Fujiwo merged commit b4463ad into main Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Fix: index.html で表示される目次に付録も表示

2 participants