Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add headings from within block groups to in-page navigation #13

Merged
merged 2 commits into from Dec 22, 2022

Conversation

brent-dxw
Copy link
Contributor

@brent-dxw brent-dxw commented Dec 13, 2022

Due to the nature of the dependencies for the changes, it is included in one commit. Technically this implements:

  • Creates a recursive findHeadingBlocks() function to walk through the blocks looking for headings
  • This needs a class-level storage of the found headings in inPageNavItems array
  • Moves the parsing of the heading object for the nav into a callable parseHeading() function
  • Refactors main getItems() method to use the above

- Previously, only headings in the root of the page were found
- This update recurses into block groups to find headings there

Technically:
- Creates a recursive findHeadingBlocks() function to walk through the blocks looking for headings
- This needs a class-level storage of the found headings in inPageNavItems array
- Moves the parsing of the heading object for the nav into a callable parseHeading() function
- Refactors main getItems() method to use the above

- Specifically, this is wanted for lambethtogether.net
-- E.g. https://lambethtogether.net/long-read/nwda-report/thriving-communities/ should have the 'Context and key challenges' in the in-page navigation

- To test, copy the above long-read or create a long read and group blocks with a heading included

- Resolves: https://dxw.zendesk.com/agent/tickets/17292 / https://dxw.zendesk.com/agent/tickets/17261
Copy link
Contributor

@jkeasley jkeasley left a comment

Choose a reason for hiding this comment

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

LGTM

RobjS
RobjS previously requested changes Dec 14, 2022
Copy link
Contributor

@RobjS RobjS left a comment

Choose a reason for hiding this comment

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

@brent-dxw Haven't tested locally yet, but the changes generally look good and make sense 👍 The InPageNavigation class has some tests it'd be good to update to reflect these changes, though.

@brent-dxw
Copy link
Contributor Author

@brent-dxw Haven't tested locally yet, but the changes generally look good and make sense 👍 The InPageNavigation class has some tests it'd be good to update to reflect these changes, though.

@RobjS Thanks - I've added a test for that

@brent-dxw brent-dxw dismissed RobjS’s stale review December 21, 2022 13:07

This has been implemented and approved in rob's absence, thanks

@brent-dxw brent-dxw merged commit 6638553 into main Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants