Fix markdown page HMR (#8418)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
837ad16491
commit
923a443cb0
3 changed files with 12 additions and 3 deletions
5
.changeset/twelve-cars-tell.md
Normal file
5
.changeset/twelve-cars-tell.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix markdown page HMR
|
|
@ -107,7 +107,7 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = escapeViteEnvReferences(`
|
const code = escapeViteEnvReferences(`
|
||||||
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent } from ${JSON.stringify(
|
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
|
||||||
astroServerRuntimeModulePath
|
astroServerRuntimeModulePath
|
||||||
)};
|
)};
|
||||||
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
|
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
|
||||||
|
@ -180,10 +180,9 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
|
||||||
}, {
|
}, {
|
||||||
'default': () => render\`\${unescapeHTML(html)}\`
|
'default': () => render\`\${unescapeHTML(html)}\`
|
||||||
})}\`;`
|
})}\`;`
|
||||||
: `render\`\${unescapeHTML(html)}\`;`
|
: `render\`\${maybeRenderHead(result)}\${unescapeHTML(html)}\`;`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Content[Symbol.for('astro.needsHeadRendering')] = ${layout ? 'false' : 'true'};
|
|
||||||
export default Content;
|
export default Content;
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
|
|
@ -49,5 +49,10 @@ describe('Pages', () => {
|
||||||
|
|
||||||
expect($('#testing').length).to.be.greaterThan(0);
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue