mirror of
https://github.com/withastro/astro.git
synced 2025-03-03 22:57:08 -05:00
Support rehype plugins that inject namespaced attributes 2 (#6253)
This commit is contained in:
parent
66acc6a65c
commit
0049fda62f
3 changed files with 7 additions and 1 deletions
5
.changeset/gentle-parrots-cheer.md
Normal file
5
.changeset/gentle-parrots-cheer.md
Normal 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`.
|
|
@ -74,6 +74,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
|
||||||
const { data: frontmatter, content: pageContent } = parseFrontmatter(code, id);
|
const { data: frontmatter, content: pageContent } = parseFrontmatter(code, id);
|
||||||
const compiled = await mdxCompile(new VFile({ value: pageContent, path: id }), {
|
const compiled = await mdxCompile(new VFile({ value: pageContent, path: id }), {
|
||||||
...mdxPluginOpts,
|
...mdxPluginOpts,
|
||||||
|
elementAttributeNameCase: 'html',
|
||||||
remarkPlugins: [
|
remarkPlugins: [
|
||||||
// Ensure `data.astro` is available to all remark plugins
|
// Ensure `data.astro` is available to all remark plugins
|
||||||
toRemarkInitializeAstroData({ userFrontmatter: frontmatter }),
|
toRemarkInitializeAstroData({ userFrontmatter: frontmatter }),
|
||||||
|
|
|
@ -63,7 +63,7 @@ describe('MDX plugins', () => {
|
||||||
expect(selectRehypeExample(document)).to.not.be.null;
|
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({
|
const fixture = await buildFixture({
|
||||||
integrations: [
|
integrations: [
|
||||||
mdx({
|
mdx({
|
||||||
|
|
Loading…
Add table
Reference in a new issue