Skip to content

Commit

Permalink
fix numbering for books with only one chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Jan 10, 2025
1 parent 0478a3f commit bc61e60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@
"engines": {
"node": "20.17.0"
}
}
}
10 changes: 5 additions & 5 deletions src/components/organisms/passageNavigation/chapterGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export default function ChapterGrid({ chapters, chapterId }: Props) {
return (
<ul className={styles.chapters}>
{chapters?.map((chapter) => {
const n = Number(chapter.title.split(' ').pop())
.toString()
.padStart(2, '0');
const n = Number(chapter.title.split(' ').pop());
const d = isFinite(n) ? n : 1;
const s = d.toString().padStart(2, '0');
return (
<li key={n} className={styles.chapter}>
<li key={s} className={styles.chapter}>
<Link
className={chapter.id === chapterId ? styles.active : ''}
href={`${chapter.canonicalPath}?autoplay`}
>
{n}
{s}
</Link>
</li>
);
Expand Down

0 comments on commit bc61e60

Please sign in to comment.