Skip to content

Conversation

@wise-king-sullyman
Copy link
Contributor

@wise-king-sullyman wise-king-sullyman commented May 29, 2025

Closes #64

convertToMdx.ts is the script which does the conversion, you can run it with npx tsx cli/cli.ts convert-to-mdx <glob path> after copying an example directory in if you'd like to test executing it yourself.

"react": "^18.3.1",
"react-docgen": "^7.1.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^6.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using this package as a quick and easy error boundary to wrap the examples in so that errors encountered when trying to render them don't crash the UI while I fine tuned the conversion. It has a few million weekly downloads on NPM so it's probably fine, but I have no strong feeling about keeping it in for the real PR.

Copy link
Member

Choose a reason for hiding this comment

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

I've used it and liked it in the past fwiw.

Comment on lines +5 to +7
import * as reactIconsModule from '@patternfly/react-icons'
import styles from "@patternfly/react-styles/css/components/_index"
import * as reactTokensModule from "@patternfly/react-tokens"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we'll want to refactor this so that we pass all of these modules via the config, but for now just doing this works. What do yall think?

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you be opposed to that being done in a followup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this issue to address #72

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is fine for now.

import PropsTables from '../../components/PropsTables.astro'
import CSSTable from '../../components/CSSTable.astro'
import SectionGallery from '../../components/section-gallery/SectionGallery.astro'
import LiveExample from '../../components/LiveExample.astro'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes to this file were needed because by default the examples are rendering at this endpoint rather than /[...tab], though I'm not sure why off hand.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think its because the nav links to components/alert (hitting page.astro and then rewriting to tab.astro) and not components/alert/react? Though it should be ultimately only hitting tab.astro though so I'm not sure either.

@wise-king-sullyman wise-king-sullyman marked this pull request as ready for review June 3, 2025 13:41
@wise-king-sullyman wise-king-sullyman changed the title DO NOT MERGE: test mdx conversion Add script for React mdx conversion Jun 3, 2025
@wise-king-sullyman wise-king-sullyman changed the title Add script for React mdx conversion feat(mdx): Add script for React mdx conversion Jun 3, 2025
Copy link
Contributor

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

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

A few comments.

convertToMDX.ts Outdated
@@ -0,0 +1,34 @@
#!/usr/bin/env ts-node
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this if we are using tsx instead of ts-node?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nope I don't think so, good catch

convertToMDX.ts Outdated
import { glob } from 'glob'

async function main() {
const files = await glob('./testContent/react/examples/*.md')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a way to have this be passed in via the command line.

convertToMDX.ts Outdated
import { readFile, writeFile } from 'fs/promises'
import { glob } from 'glob'

async function main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this should be part of the cli.

Comment on lines +5 to +7
import * as reactIconsModule from '@patternfly/react-icons'
import styles from "@patternfly/react-styles/css/components/_index"
import * as reactTokensModule from "@patternfly/react-tokens"
Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me.

@wise-king-sullyman wise-king-sullyman requested a review from dlabaj June 3, 2025 20:24
@dlabaj dlabaj merged commit 0c7212c into main Jun 9, 2025
1 check passed
@github-actions
Copy link

github-actions bot commented Jun 9, 2025

🎉 This PR is included in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test updating react-core example files to MDX format

5 participants