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

Extract MDX headings #16

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open

Extract MDX headings #16

wants to merge 2 commits into from

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.0.1--canary.16.72d7283.0

✨ Test out this PR locally via:

npm install @storybook/docs-mdx@3.0.1--canary.16.72d7283.0
# or 
yarn add @storybook/docs-mdx@3.0.1--canary.16.72d7283.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 👏

@@ -151,6 +153,17 @@ export const extractImports = (root: t.File) => {
return varToImport;
};

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.

None yet

2 participants