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

[Markdoc] headings and heading IDs #7095

Merged
merged 18 commits into from
May 17, 2023
Merged

[Markdoc] headings and heading IDs #7095

merged 18 commits into from
May 17, 2023

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented May 15, 2023

Changes

  • Resolves Getting headings from a markdoc file using the render() method returns an empty object. #6855
  • Generate heading IDs for all Markdoc headings
  • Populate the headings array from the render() function
    • Create a new @astrojs/markdoc/runtime export that exposes a collectHeadings utility
    • Add a getHeadings() function to all .mdoc modules. This approach will call transform twice (once for the Content component, once for getHeadings()). This is due to a fundamental limitation of allowing Markdoc variables as component props. A TODO for a future exploration is noted in the source code.
  • Expose a defaultNodes object to use when modifying nodes from the Markdoc config

Testing

  • Test heading IDs and TOC
  • Test rendering component Astro components

Docs

Update Node headings example in the README. In the future, we may need to document each node case-by-case!

@bholmesdev bholmesdev requested a review from a team as a code owner May 15, 2023 20:21
@changeset-bot
Copy link

changeset-bot bot commented May 15, 2023

🦋 Changeset detected

Latest commit: 11c388f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bholmesdev bholmesdev self-assigned this May 15, 2023
@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) labels May 15, 2023
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Let's ship it! 🚢

@bholmesdev bholmesdev merged commit fb84622 into main May 17, 2023
@bholmesdev bholmesdev deleted the feat/markdoc-headings branch May 17, 2023 13:13
@sarah11918
Copy link
Member

Just a quick heads up @bholmesdev that I literally saw this merge as I was looking at the README! Reminder for next time! ❤️

@astrobot-houston astrobot-houston mentioned this pull request May 17, 2023
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Late to the party (whomp, whomp) but README docs are great! 🎉

@bholmesdev
Copy link
Contributor Author

@sarah11918 CRAP I 100% forgot to tag you on this 😓 Assumed we'd reviewed it with all the docs PRs flying around. If you want to leave comments here for me to address in a fast follow, happy to do so

@sarah11918
Copy link
Member

sarah11918 commented May 17, 2023

Sorry @bholmesdev - I was prioritizing the specific "merge on release" docs I'd been given (and, didn't know this Markdoc update was something to be released for 2.5) so I assumed this was a "regular" PR, and was just clearing out all the Astro Docs Maintainer pings now. Docs are great though! No worries!

@bholmesdev
Copy link
Contributor Author

It is a "regular" PR, was just itching to merge to align Markdoc 0.2.0 with some data collection changes. I'll check next time, my bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting headings from a markdoc file using the render() method returns an empty object.
4 participants