Skip to content

Comments

Extract MDX headings#16

Open
shilman wants to merge 4 commits intonextfrom
shilman/extract-mdx-headings
Open

Extract MDX headings#16
shilman wants to merge 4 commits intonextfrom
shilman/extract-mdx-headings

Conversation

@shilman
Copy link
Member

@shilman shilman commented Mar 16, 2024

Issue: N/A

What Changed

Extract h1-h4 MDX headings for better search

How to test

See unit tests

Change Type

  • maintenance
  • documentation
  • patch
  • minor
  • major
📦 Published PR as canary version: 3.1.1--canary.16.129f63c.0

✨ Test out this PR locally via:

npm install @storybook/docs-mdx@3.1.1--canary.16.129f63c.0
# or 
yarn add @storybook/docs-mdx@3.1.1--canary.16.129f63c.0

@shilman shilman requested a review from JReinhold as a code owner March 16, 2024 15:38
Copy link
Member

@kroeder kroeder left a comment

Choose a reason for hiding this comment

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

Awesome @shilman 👏


export const getHeadings = (root: any) => {
const headings = [] as string[];
['h1', 'h2', 'h3', 'h4'].forEach((tag) => {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be difficult to have options for that? People probably have different opinions about "what should be searchable" and maybe want something like

docs: {
  includeInSearch: 'h1, h2'
}

or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I'll implement it all end-to-end using this simple method and then see how disruptive it is to make it configurable

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.

3 participants