Skip to content

Commit

Permalink
Fix markdown page HMR (#8418)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
bluwy and natemoo-re authored Sep 5, 2023
1 parent 837ad16 commit 923a443
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-cars-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix markdown page HMR
5 changes: 2 additions & 3 deletions packages/astro/src/vite-plugin-markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
}

const code = escapeViteEnvReferences(`
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent } from ${JSON.stringify(
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
astroServerRuntimeModulePath
)};
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
Expand Down Expand Up @@ -180,10 +180,9 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
}, {
'default': () => render\`\${unescapeHTML(html)}\`
})}\`;`
: `render\`\${unescapeHTML(html)}\`;`
: `render\`\${maybeRenderHead(result)}\${unescapeHTML(html)}\`;`
}
});
Content[Symbol.for('astro.needsHeadRendering')] = ${layout ? 'false' : 'true'};
export default Content;
`);

Expand Down
5 changes: 5 additions & 0 deletions packages/astro/test/astro-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ describe('Pages', () => {

expect($('#testing').length).to.be.greaterThan(0);
});

it('should have Vite client in dev', async () => {
const html = await fixture.fetch('/').then((res) => res.text());
expect(html).to.include('/@vite/client', 'Markdown page does not have Vite client for HMR');
});
});
});

0 comments on commit 923a443

Please sign in to comment.