From f5e634fe5833a78268beedefbb314f2dc6d97978 Mon Sep 17 00:00:00 2001 From: Joshua Ryder Date: Wed, 1 Oct 2025 10:12:01 -0400 Subject: [PATCH] Fix chapter navigation to use proper numerical ordering instead of alphabetical --- backend/src/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/index.js b/backend/src/index.js index 46089cb0..8c42fecd 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -180,10 +180,12 @@ app.get('/books/:book', async (req, res) => { } // Extract chapter numbers from filenames (e.g., "Chapter_01.md" -> "1") - const chapters = chapterFiles.map(file => { + const chapterNumbers = chapterFiles.map(file => { const match = file.match(/Chapter_(\d+)\.md$/); - return match ? parseInt(match[1], 10).toString() : null; - }).filter(Boolean); + return match ? parseInt(match[1], 10) : null; + }).filter(Boolean).sort((a, b) => a - b); + + const chapters = chapterNumbers.map(num => num.toString()); res.json({ chapters, version }); } catch (error) {