chore(usage): rename playground index partials to .mdx - #4662
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me, great work! Just the i18n coupling I'd like made order-proof first
| By default, all Ionic Animations are paused until the `play` method is called. | ||
|
|
||
| import Basic from '@site/static/usage/v9/animations/basic/index.md'; | ||
| import Basic from '@site/static/usage/v9/animations/basic/index.mdx'; |
There was a problem hiding this comment.
You've already got the coupling written up on #4663, so this is just the measurement from this side: building --locale ja on this branch exits 1 with 428 Cannot find module errors, one for every usage import in the i18n/ja tree that i18n.sh pulls.
Same worry I had on the api partials, and the same ask: can we make this safe whatever order things merge in? Back to back is fine right up until something else merges to main in the gap, and nothing here would catch that, since CI never builds and previews are --locale en. Adding resolve.extensionAlias with '.md': ['.mdx', '.md'] to the configureWebpack hook in the component-api plugin would do it without 863 duplicate files, though it does apply to every .md import in the repo, so a genuinely missing file stops being an error. I'd want it carrying the same TODO(FW-6456) note as the transitional block above it, and something filed to track dropping it.
| In some cases, you may need to access the current Ionic mode programmatically within your application logic. This can be useful for applying conditional behavior, fetching specific assets, or performing other actions based on the active styling mode. | ||
|
|
||
| import IonicMode from '@site/static/usage/v9/config/mode/index.md'; | ||
| import IonicMode from '@site/static/usage/v9/config/mode/index.mdx'; |
There was a problem hiding this comment.
The five @site/docs/developing/config partials imported above this line are the same shape as the ones you're renaming here, imports and Tabs JSX inside a .md file. #4663 says they're coming in a later PR in the series, which works for me. Could you file something to track it? Nothing on this PR says they're deferred, and this series has enough moving parts that I'd rather it didn't live only in a sibling PR's description.
One thing for whoever picks it up: versioned_docs/version-v8/developing/config/*/index.md exists too, but nothing reads it, since the v8 page imports these current-version copies instead of its own.
There was a problem hiding this comment.
I've updated the Jira ticket to keep track of this.
| const playgroundName = changeCase.pascal(answers.path.split('/').pop()); | ||
| console.log( | ||
| `\nTo use this playground in a docs markdown file, include\nthe following:\n\n## ${playgroundName}\n\nimport ${playgroundName} from '@site/static/usage/v${answers.version}/${answers.name}/${answers.path}/index.md';\n\n<${playgroundName} />\n` | ||
| `\nTo use this playground in a docs markdown file, include\nthe following:\n\n## ${playgroundName}\n\nimport ${playgroundName} from '@site/static/usage/v${answers.version}/${answers.name}/${answers.path}/index.mdx';\n\n<${playgroundName} />\n` |
There was a problem hiding this comment.
Nit: the version prompt above still offers choices: ['6', '7', '8', '9'], so picking 6 or 7 scaffolds an index.mdx into a tree that's otherwise all index.md. Up to you whether that's worth trimming, I doubt anyone's picking them at this point.
There was a problem hiding this comment.
I'll create a PR for this since Contributing will also need to be updated.
Issue URL: internal
What is the current behavior?
Playground partials under
static/usageare namedindex.md, but they are MDX files: each one imports thePlaygroundcomponent and renders it as JSX. They only work today because Docusaurus resolves them through its MDX fallback loader, which honorsmarkdown.format, and that option still defaults tomdx.Docusaurus is moving toward Strict MDX, where
.mdis parsed as CommonMark instead. When that default changes, every one of these files would have its imports and JSX treated as literal text, and all playgrounds would stop rendering.What is the new behavior?
index.mdis renamed toindex.mdxacross the two live usage trees,static/usage/v8andstatic/usage/v9, for 863 files total. The 880 imports that reference them, 441 indocsand 439 inversioned_docs/version-v8, are updated to match.The playground generator is updated so newly created playgrounds emit
index.mdxfrom the start, along with the usage example in the templates README.The component API plugin gains a
resolve.extensionAliasentry mapping.mdto.mdxand then.md, so an import written with the old extension still resolves after the rename. This is what makes this PR and its translation branch companion independent of merge order. It carries aTODO(FW-6456)marker and comes out once every branch is migrated, alongside the dual-write it supersedes.Two things are deliberately left alone:
The per-framework snippet files, such as
javascript.mdandreact.md, stay as.mdbecause each one is a single fenced code block containing no imports or JSX, so the extension already matches what is in them.Archived versions are untouched.
static/usage/v6andstatic/usage/v7keep their 713index.mdfiles, since those versions are never built.Does this introduce a breaking change?
Other information
The companion PR on
translation/jpstill needs to land, but it is no longer order sensitive.The Japanese site is built from this branch's tree combined with prose pulled from the translation branch, and both sides reference partials by explicit path including the extension. Renaming on either side alone used to break the other, and because preview builds run
--locale en, nothing here would catch it. It would surface only on the production deploy. TheextensionAliasentry removes that coupling, so the two PRs can merge in any order and with any gap between them.Verification performed locally:
Building
--locale jaagainst the unmerged translation branch reproduces the original failure exactly: 428 unresolved modules, exit 1. All 428 have an.mdxcounterpart on disk, so it is purely the extension. With the alias in place the same build completes, emitting 2298 pages with 0 errors and playgrounds rendering.The resolver behavior was characterized directly rather than assumed. A request for a
.mdfile with neither file present is still a build error, so genuinely missing files do not go quiet. The only new behavior is.mdxwinning when both exist, which already describes the 950 dual-written API partials.A full English production build passes, reporting 0 errors, 0 warnings, 0 unresolved modules, and 0 broken links. The single broken anchor it reports predates this work and is unrelated:
glossary.mddefinesweb-standardsas a raw HTML section id, which the anchor checker does not index because it only reads heading IDs. That file is not in this diff.Prettier reports no files needing changes repo wide. Worth noting that the rename is parser neutral, because
@ionic/prettier-configalready forces themdxparser for*.md.All 855 unique import targets were confirmed to exist on disk, and a repo wide sweep found no remaining reference to a v8 or v9 usage
index.mdin any file type.The five partials under
docs/developing/configare the same shape and are not renamed here. They ride along with the doc page rename, since they need the translation branch to change in the same window. That work is tracked on the ticket, along with two problems found in those files: two imports crossed against their directories, and a set of v8 copies that nothing reads.Refer to the Docusaurus 3.10 Strict MDX release note for background.
How to test
Open each page below and confirm the playgrounds still render. The rename only affects how the partials are imported, so a failure shows up as a missing or blank playground rather than as broken prose.
On each page, check that:
Every playground appears, with its live demo loading in the embedded frame.
Switching between the Angular, React, Vue, and JavaScript tabs shows the code for each. A playground can render correctly while its tabs come up empty, so this is the only step that confirms the code snippets themselves loaded.
No raw text such as an
importline or a literal component tag is visible anywhere in the rendered page. That would mean a partial was parsed as plain markdown instead of MDX.