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

Core: Update index generation to use tags to detect MDX stories #19712

Merged
merged 10 commits into from
Nov 7, 2022

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Nov 2, 2022

Issue: N/A

What I did

Use storybookjs/mdx2-csf#22 to set mdx tag, and use it to determine which files need a docs page (rather than matching on filename).

@tmeasday
Copy link
Member Author

tmeasday commented Nov 2, 2022

@shilman there doesn't appear to be a new next version of @storybook/mdx2-csf just yet.

@tmeasday tmeasday added the maintenance User-facing maintenance tasks label Nov 2, 2022
@tmeasday
Copy link
Member Author

tmeasday commented Nov 2, 2022

OK! This PR works, just need to figure out the test for the indexer.

@tmeasday tmeasday changed the title Update client-api to use tags instead of filename to detect MDX stories Core: Update index generation to use tags instead of filename to detect MDX stories Nov 3, 2022
@tmeasday tmeasday changed the title Core: Update index generation to use tags instead of filename to detect MDX stories Core: Update index generation to use tags instead of filename to detect MDX Nov 3, 2022
@tmeasday tmeasday changed the title Core: Update index generation to use tags instead of filename to detect MDX Core: Update index generation to use tags to detect MDX Nov 3, 2022
@tmeasday tmeasday changed the title Core: Update index generation to use tags to detect MDX Core: Update index generation to use tags to detect MDX stories Nov 3, 2022
@tmeasday
Copy link
Member Author

tmeasday commented Nov 3, 2022

Nice job @shilman! Will mark this ready for review once storybookjs/mdx2-csf#23 is merged and we can switch back to next

Copy link
Member

shilman commented Nov 3, 2022

Merged. I suspect there are bugs in this PR. If you browse the sandbox "csf in mdx" docs page it's blank @tmeasday

@tmeasday
Copy link
Member Author

tmeasday commented Nov 4, 2022

@shilman it turned out to be a simple missing import, not sure how/if it was working before but an easy fix!

@tmeasday tmeasday marked this pull request as ready for review November 4, 2022 02:27
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM with one q

"tags": Array [
"story-tag",
"mdx",
Copy link
Member

Choose a reason for hiding this comment

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

Just confirming that the mdx tag here means that the story was generated from MDX. Do we want that? It could be confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

That was intentional on my part anyway. Happy to change the tag from mdx if it is confusing that a story can be "mdx". To me it makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

WFM after letting it settle in

@tmeasday
Copy link
Member Author

tmeasday commented Nov 4, 2022

@shilman for some reason the stories.json.test.ts file has started crashing. When I run the test locally I see this a lot:

WARN 🚨 Extraction error on src/nested/Page.stories.mdx: SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (5:0)

When I change Page.stories.mdx to:

import { Meta, Story } from '@storybook/addon-docs';

<>
<Meta component={{}} />

<Story name="StoryOne" />
 </>

The problem goes away. But I don't think that's right is it?

@shilman shilman merged commit 01ee7b5 into next Nov 7, 2022
@shilman shilman deleted the tom/sb-882-use-mdx-tag-instead-of-matching-on branch November 7, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: docs core maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants