@astrojs/mdx 0.18.2 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- @astrojs/mdx:build: cache hit, replaying output 83b53c3b3706ec68
1
+ @astrojs/mdx:build: cache hit, replaying output 603ca93f0d424089
2
2
  @astrojs/mdx:build: 
3
- @astrojs/mdx:build: > @astrojs/mdx@0.18.2 build /home/runner/work/astro/astro/packages/integrations/mdx
3
+ @astrojs/mdx:build: > @astrojs/mdx@0.18.3 build /home/runner/work/astro/astro/packages/integrations/mdx
4
4
  @astrojs/mdx:build: > astro-scripts build "src/**/*.ts" && tsc
5
5
  @astrojs/mdx:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @astrojs/mdx
2
2
 
3
+ ## 0.18.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#6779](https://github.com/withastro/astro/pull/6779) [`a98f6f418`](https://github.com/withastro/astro/commit/a98f6f418c92261a06ef79624a8c86e288c21eab) Thanks [@matthewp](https://github.com/matthewp)! - Prevent body head content injection in MDX when using layout
8
+
3
9
  ## 0.18.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -122,6 +122,8 @@ export const Content = (props = {}) => MDXContent({
122
122
  }
123
123
  code += `
124
124
  Content[Symbol.for('astro.needsHeadRendering')] = !Boolean(frontmatter.layout);`;
125
+ code += `
126
+ Content.moduleId = ${JSON.stringify(id)};`;
125
127
  if (command === "dev") {
126
128
  code += `
127
129
  if (import.meta.hot) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/mdx",
3
3
  "description": "Add support for MDX pages in your Astro site",
4
- "version": "0.18.2",
4
+ "version": "0.18.3",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -23,7 +23,7 @@
23
23
  "./package.json": "./package.json"
24
24
  },
25
25
  "dependencies": {
26
- "@astrojs/markdown-remark": "^2.1.1",
26
+ "@astrojs/markdown-remark": "^2.1.3",
27
27
  "@astrojs/prism": "^2.1.1",
28
28
  "@mdx-js/mdx": "^2.3.0",
29
29
  "@mdx-js/rollup": "^2.3.0",
@@ -48,7 +48,7 @@
48
48
  "@types/mdast": "^3.0.10",
49
49
  "@types/mocha": "^9.1.1",
50
50
  "@types/yargs-parser": "^21.0.0",
51
- "astro": "2.1.4",
51
+ "astro": "2.2.1",
52
52
  "astro-scripts": "0.0.14",
53
53
  "chai": "^4.3.6",
54
54
  "cheerio": "^1.0.0-rc.11",
@@ -63,7 +63,7 @@
63
63
  "remark-rehype": "^10.1.0",
64
64
  "remark-shiki-twoslash": "^3.1.0",
65
65
  "remark-toc": "^8.0.1",
66
- "vite": "^4.1.2"
66
+ "vite": "^4.2.1"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=16.12.0"
package/src/index.ts CHANGED
@@ -160,6 +160,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
160
160
  // Ensures styles and scripts are injected into a `<head>`
161
161
  // When a layout is not applied
162
162
  code += `\nContent[Symbol.for('astro.needsHeadRendering')] = !Boolean(frontmatter.layout);`;
163
+ code += `\nContent.moduleId = ${JSON.stringify(id)};`;
163
164
 
164
165
  if (command === 'dev') {
165
166
  // TODO: decline HMR updates until we have a stable approach
@@ -81,5 +81,18 @@ describe('Head injection w/ MDX', () => {
81
81
  const bodyLinks = $('body link[rel=stylesheet]');
82
82
  expect(bodyLinks).to.have.a.lengthOf(0);
83
83
  });
84
+
85
+ it('Injection caused by delayed slots', async () => {
86
+ const html = await fixture.readFile('/componentwithtext/index.html');
87
+
88
+ // Using cheerio here because linkedom doesn't support head tag injection
89
+ const $ = cheerio.load(html);
90
+
91
+ const headLinks = $('head link[rel=stylesheet]');
92
+ expect(headLinks).to.have.a.lengthOf(1);
93
+
94
+ const bodyLinks = $('body link[rel=stylesheet]');
95
+ expect(bodyLinks).to.have.a.lengthOf(0);
96
+ });
84
97
  });
85
98
  });
@@ -0,0 +1,14 @@
1
+ ---
2
+ const { inlineStyle, title, display = 'horizontal' } = Astro.props;
3
+ const lineEnding = display === 'horizontal' ? ', ' : '<br>';
4
+ ---
5
+
6
+ {title && <h2 set:html={title} />}
7
+ <address style={inlineStyle}>
8
+ <span class="name">some name</span><Fragment set:html={lineEnding} />
9
+ line 1<Fragment set:html={lineEnding} />
10
+ line 2<Fragment set:html={lineEnding} />
11
+ line 3<Fragment set:html={lineEnding} />
12
+ line 4<Fragment set:html={lineEnding} />
13
+ line 5
14
+ </address>
@@ -0,0 +1,15 @@
1
+ ---
2
+ // Extend the BaseLayout, adding space for a banner at the top of the page
3
+ // after the main heading, then the detail for the actual page
4
+ import ContentLayout from './ContentLayout.astro';
5
+ const { frontmatter } = Astro.props;
6
+ ---
7
+
8
+ <ContentLayout>
9
+ <div class="content-container">
10
+ <article id="main-content" class="pad-z5 flow">
11
+ <h1 set:html={frontmatter.pageHeading ? frontmatter.pageHeading : frontmatter.title} />
12
+ <slot />
13
+ </article>
14
+ </div>
15
+ </ContentLayout>
@@ -0,0 +1,12 @@
1
+ ---
2
+ layout: ../layouts/DocumentLayout.astro
3
+ title: blah blah
4
+ ---
5
+
6
+ import BasicBlock from '../components/BasicBlock.astro';
7
+
8
+ Some text for a paragraph.
9
+
10
+ <BasicBlock title="This causes css in wrong place." />
11
+
12
+ Some other text.