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")
|
// 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$/);
|
const match = file.match(/Chapter_(\d+)\.md$/);
|
||||||
return match ? parseInt(match[1], 10).toString() : null;
|
return match ? parseInt(match[1], 10) : null;
|
||||||
}).filter(Boolean);
|
}).filter(Boolean).sort((a, b) => a - b);
|
||||||
|
|
||||||
|
const chapters = chapterNumbers.map(num => num.toString());
|
||||||
|
|
||||||
res.json({ chapters, version });
|
res.json({ chapters, version });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user