Skip to content

Prevent duplicate chapter title and first in-page nav item - #46

Merged
RobjS merged 1 commit into
mainfrom
fix/prevent-duplicate-page-title-and-in-page-nav
Jul 16, 2026
Merged

Prevent duplicate chapter title and first in-page nav item#46
RobjS merged 1 commit into
mainfrom
fix/prevent-duplicate-page-title-and-in-page-nav

Conversation

@RobjS

@RobjS RobjS commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

For page-break based long reads, we have to assume that the first heading block after a page break is the title of that page/chapter.

However, we assemble the in-page nav by getting all the h2 heading blocks within that chapter.

This meant that if the first heading after a page break was an h2, that heading would be used as both the title of the chapter in the side nav, and as the first in-page nav item of that chapter.

This change checks if the title of the first in-page nav item matches the chapter title, and if so, it removes that in-page nav item.

Resolves: #44

How to test

  1. Checkout the main branch
  2. Create a page-break based long read, where the first heading block in the second page is an h2
  3. Observe that that h2 is rendered in the side nav as both the title of that chapter and the first in-page nav item of that chapter
  4. Checkout this branch
  5. The heading should now only be used as the chapter title, and the in-page nav items should start with the second heading in the page

Checklist

  • Changelog updated
  • If new release: major version tag to be bumped after release (see docs)

For page-break based long reads, we have to assume that the first
heading block after a page break is the title of that page/chapter.

However, we assemble the in-page nav by getting all the h2 heading
blocks within that chapter.

This meant that if the first heading after a page break was an h2, that
heading would be used as both the title of the chapter in the side nav,
and as the first in-page nav item of that chapter.

This change checks if the title of the first in-page nav item matches
the chapter title, and if so, it removes that in-page nav item.

Resolves: #44

@matthewpassmore matthewpassmore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected 👍

Ignore my flagged issues in the previous PR. I didn't realise that an env var needed setting 🤦

@RobjS

RobjS commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Works as expected 👍

Ignore my flagged issues in the previous PR. I didn't realise that an env var needed setting 🤦

I should have made that clearer in the testing instructions, sorry!

@RobjS
RobjS merged commit 95171f3 into main Jul 16, 2026
2 checks passed
@RobjS
RobjS deleted the fix/prevent-duplicate-page-title-and-in-page-nav branch July 16, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page-break-based long reads can duplicate first h2 in nav

2 participants