d25f54cb93
* feat(vue): add support for appEntrypoint * chore: add changeset * test(vue): add tests for app entrypoint * docs(vue): update README to include app entrypoint * fix(vue): prefer resolvedVirtualModuleId Co-authored-by: Nate Moore <nate@astro.build>
24 lines
724 B
JavaScript
24 lines
724 B
JavaScript
import { h, createSSRApp } from 'vue';
|
|
import { renderToString } from 'vue/server-renderer';
|
|
import { setup } from 'virtual:@astrojs/vue/app'
|
|
import StaticHtml from './static-html.js';
|
|
|
|
function check(Component) {
|
|
return !!Component['ssrRender'] || !!Component['__ssrInlineRender'];
|
|
}
|
|
|
|
async function renderToStaticMarkup(Component, props, slotted) {
|
|
const slots = {};
|
|
for (const [key, value] of Object.entries(slotted)) {
|
|
slots[key] = () => h(StaticHtml, { value, name: key === 'default' ? undefined : key });
|
|
}
|
|
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
|
await setup(app);
|
|
const html = await renderToString(app);
|
|
return { html };
|
|
}
|
|
|
|
export default {
|
|
check,
|
|
renderToStaticMarkup,
|
|
};
|