Skip to content

Commit c6eddfd

Browse files
piti6claude
andcommitted
fix: address second round of Copilot review feedback
- Sort htmlFiles for deterministic search index output - Bound final section to book content, excluding script/footer - Add aria-label to search input for accessibility - Skip h2 headings without id in sub-section TOC generation - Use ruby-version-file in CI to match .ruby-version - Use npm ci for reproducible CI builds - Use YAML.safe_load_file instead of YAML.load_file - Update engines.node to >=16.0.0 (required by grunt 1.6.1) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f2ff6a commit c6eddfd

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/deploy-web.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Ruby
2525
uses: ruby/setup-ruby@v1
2626
with:
27-
ruby-version: '3.3'
27+
ruby-version-file: '.ruby-version'
2828
bundler-cache: true
2929

3030
- name: Setup Node.js
@@ -34,7 +34,7 @@ jobs:
3434
cache: 'npm'
3535

3636
- name: Install npm dependencies
37-
run: npm install --ignore-scripts
37+
run: npm ci --ignore-scripts
3838

3939
- name: Build web pages (JP + EN)
4040
run: npm run web

articles/layouts/layout-web.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<a href="#" class="lang-btn" data-lang="en">English</a>
3535
</div>
3636
<div class="search-box">
37-
<input type="text" id="search-input" placeholder="Search..." autocomplete="off" />
37+
<input type="text" id="search-input" placeholder="Search..." autocomplete="off" aria-label="Search" />
3838
<div id="search-results" class="search-results"></div>
3939
</div>
4040
<%= @toc %>
@@ -111,6 +111,7 @@
111111
subUl.className = 'toc-sub';
112112
headings.forEach(function(h2) {
113113
var id = h2.getAttribute('id');
114+
if (!id) return;
114115
var text = h2.textContent.replace(/^\s+/, '');
115116
var subLi = document.createElement('li');
116117
var subA = document.createElement('a');

articles/lib/tasks/z01_pandoc2review.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end
3232

3333
desc 'run pandoc2review'
3434
task :pandoc2review do
35-
config = YAML.load_file(CONFIG_FILE, permitted_classes: [Date])
35+
config = YAML.safe_load_file(CONFIG_FILE, permitted_classes: [Date])
3636
if config['contentdir'] == '_refiles'
3737
path = '_refiles'
3838
p2r = 'pandoc2review'

build-search-index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const path = require("path");
99
const webroot = process.argv[2] || path.join(__dirname, "articles", "webroot");
1010
const outFile = path.join(webroot, "search-index.json");
1111

12-
const htmlFiles = fs.readdirSync(webroot).filter(f => f.endsWith(".html") && f !== "index.html" && f !== "titlepage.html");
12+
const htmlFiles = fs.readdirSync(webroot).filter(f => f.endsWith(".html") && f !== "index.html" && f !== "titlepage.html").sort();
1313

1414
const index = [];
1515

@@ -39,7 +39,8 @@ htmlFiles.forEach(file => {
3939
// Index each section — use positions from full html since headings were matched against it
4040
for (let i = 0; i < headings.length; i++) {
4141
const start = headings[i].pos;
42-
const end = i + 1 < headings.length ? headings[i + 1].pos : html.length;
42+
const naviPos = html.indexOf('<nav class="book-navi');
43+
const end = i + 1 < headings.length ? headings[i + 1].pos : (naviPos !== -1 ? naviPos : html.length);
4344
const sectionHtml = html.slice(start, end);
4445
const text = stripTags(sectionHtml).slice(0, 500);
4546
sections.push({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"homepage": "https://github.com/CyberAgentGameEntertainment/UnityPerformanceTuningBible/blob/main/README.md",
1616
"engines": {
17-
"node": ">=6.0.0"
17+
"node": ">=16.0.0"
1818
},
1919
"scripts": {
2020
"global-bundler": "gem install bundler",

0 commit comments

Comments
 (0)