Fix chapter navigation to use proper numerical ordering instead of alphabetical
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user