govuk-design-system icon indicating copy to clipboard operation
govuk-design-system copied to clipboard

Use `getHeadingList` from `marked-gfm-heading-id` plugin

Open patrickpatrickpatrick opened this issue 9 months ago • 1 comments

What

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

Addresses issue https://github.com/alphagov/govuk-design-system/issues/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.

patrickpatrickpatrick avatar May 13 '24 10:05 patrickpatrickpatrick

You can preview this change here:

Name Link
Latest commit 68926d7b18f1fde7ce495878a9c9b762ca05b66b
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.

netlify[bot] avatar May 13 '24 10:05 netlify[bot]

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 :)

patrickpatrickpatrick avatar May 15 '24 10:05 patrickpatrickpatrick