Support rehype plugins that inject namespaced attributes 2 (#6253)

This commit is contained in:
Bjorn Lu 2023-02-16 18:53:30 +08:00 committed by GitHub
parent 66acc6a65c
commit 0049fda62f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/mdx': minor
---
Support rehype plugins that inject namespaced attributes. This introduces a breaking change if you use [custom components for HTML elements](https://docs.astro.build/en/guides/markdown-content/#assigning-custom-components-to-html-elements), where the prop passed to the component will be normal HTML casing, e.g. `class` instead of `className`, and `xlink:href` instead of `xlinkHref`.

View file

@ -74,6 +74,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
const { data: frontmatter, content: pageContent } = parseFrontmatter(code, id);
const compiled = await mdxCompile(new VFile({ value: pageContent, path: id }), {
...mdxPluginOpts,
elementAttributeNameCase: 'html',
remarkPlugins: [
// Ensure `data.astro` is available to all remark plugins
toRemarkInitializeAstroData({ userFrontmatter: frontmatter }),

View file

@ -63,7 +63,7 @@ describe('MDX plugins', () => {
expect(selectRehypeExample(document)).to.not.be.null;
});
it.skip('supports custom rehype plugins with namespaced attributes', async () => {
it('supports custom rehype plugins with namespaced attributes', async () => {
const fixture = await buildFixture({
integrations: [
mdx({