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

Use getHeadingList from marked-gfm-heading-id plugin #3793

Merged
merged 1 commit into from
May 16, 2024

Conversation

patrickpatrickpatrick
Copy link
Contributor

@patrickpatrickpatrick patrickpatrickpatrick commented May 13, 2024

What

Delete extractHeadingPageHeadings(). Write new Metalsmith plugin that adds headings to each file object after each markdown file has been processed.

Addresses issue #3171.

Why

Remove extra implementation to make use of already implemented feature of marked-gfm-heading-id. This method of implementation means we don't have parse the markdown multiple times and removes a loop of all the processed files.

Copy link

netlify bot commented May 13, 2024

You can preview this change here:

Name Link
🔨 Latest commit 68926d7
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/66448d869a7ca400085f6c21
😎 Deploy Preview https://deploy-preview-3793--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@patrickpatrickpatrick patrickpatrickpatrick force-pushed the getheadinglist branch 4 times, most recently from b08c46a to 8ee1d04 Compare May 13, 2024 11:04
@patrickpatrickpatrick patrickpatrickpatrick marked this pull request as ready for review May 13, 2024 11:19
@patrickpatrickpatrick patrickpatrickpatrick requested a review from a team May 13, 2024 11:21
@patrickpatrickpatrick patrickpatrickpatrick changed the title Use get heading list Use getHeadingList in extractPageHeadings May 13, 2024
@patrickpatrickpatrick patrickpatrickpatrick changed the title Use getHeadingList in extractPageHeadings Use getHeadingList from marked-gfm-heading-id plugin May 14, 2024
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

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

Cheers for picking this one up. The new plugin looks neat. 🙌🏻

Given it does a little more than simple markdown rendering now and is responsible for extracting headings info as well, I'd be keen to keep the tests we had for extract-page-headings to validate that it does that part of the work correctly.

The tests of the metalsmith-lunr-index will validate some of that, but having specific examples for each feature of the heading extraction (aliases, excluding from navigation, excluding from search) will make it easier to understand what exactly the heading extraction is about.

Would you mind adding them back (that'll probably require the plugin file to move in a folder in a similar way that the previous plugin was set up), please?

Comment on lines 11 to 12
* Renders markdown and extracts headings from markdown
* and assigns to 'headings' variable of each file.
Copy link
Member

Choose a reason for hiding this comment

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

Cheers for adding a little description to the JSDoc on top of the title 😊

@patrickpatrickpatrick patrickpatrickpatrick force-pushed the getheadinglist branch 2 times, most recently from b2c454a to b34ccbd Compare May 15, 2024 10:21
@patrickpatrickpatrick
Copy link
Contributor Author

Cheers for picking this one up. The new plugin looks neat. 🙌🏻

Given it does a little more than simple markdown rendering now and is responsible for extracting headings info as well, I'd be keen to keep the tests we had for extract-page-headings to validate that it does that part of the work correctly.

The tests of the metalsmith-lunr-index will validate some of that, but having specific examples for each feature of the heading extraction (aliases, excluding from navigation, excluding from search) will make it easier to understand what exactly the heading extraction is about.

Would you mind adding them back (that'll probably require the plugin file to move in a folder in a similar way that the previous plugin was set up), please?

Makes sense. Was able to just add them all back with minimal changes :)

The `getHeadingList` function was introduced in a recent update to the
`marked-gfm-heading-id` marked plugin. This commit removes
`extractPageHeadings` and adds a new Metalsmith markdown plugin which
adds headings to the `files` as the markdown is processed.
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

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

Makes sense. Was able to just add them all back with minimal changes :)
🌟 Ace, hoped that we could reuse most of what was there. Thanks for updating.

@patrickpatrickpatrick patrickpatrickpatrick merged commit d4ae477 into main May 16, 2024
13 checks passed
@patrickpatrickpatrick patrickpatrickpatrick deleted the getheadinglist branch May 16, 2024 13:28
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.

None yet

2 participants