Skip to content

Commit 923a443

Browse files
bluwynatemoo-re
andauthored
Fix markdown page HMR (#8418)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
1 parent 837ad16 commit 923a443

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

.changeset/twelve-cars-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fix markdown page HMR

packages/astro/src/vite-plugin-markdown/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
107107
}
108108

109109
const code = escapeViteEnvReferences(`
110-
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent } from ${JSON.stringify(
110+
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
111111
astroServerRuntimeModulePath
112112
)};
113113
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
@@ -180,10 +180,9 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
180180
}, {
181181
'default': () => render\`\${unescapeHTML(html)}\`
182182
})}\`;`
183-
: `render\`\${unescapeHTML(html)}\`;`
183+
: `render\`\${maybeRenderHead(result)}\${unescapeHTML(html)}\`;`
184184
}
185185
});
186-
Content[Symbol.for('astro.needsHeadRendering')] = ${layout ? 'false' : 'true'};
187186
export default Content;
188187
`);
189188

packages/astro/test/astro-pages.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,10 @@ describe('Pages', () => {
4949

5050
expect($('#testing').length).to.be.greaterThan(0);
5151
});
52+
53+
it('should have Vite client in dev', async () => {
54+
const html = await fixture.fetch('/').then((res) => res.text());
55+
expect(html).to.include('/@vite/client', 'Markdown page does not have Vite client for HMR');
56+
});
5257
});
5358
});

0 commit comments

Comments
 (0)