chore: improve app setup call

This commit is contained in:
yoyo837 2023-10-10 23:12:01 +08:00
parent 9cd6a6657b
commit ee5d84a665
2 changed files with 6 additions and 2 deletions

View file

@ -24,7 +24,9 @@ export default (element) =>
const isHydrate = client !== 'only';
const boostrap = isHydrate ? createSSRApp : createApp;
const app = boostrap({ name, render: () => content });
await setup(app);
if (typeof setup === 'function') {
await setup(app);
}
app.mount(element, isHydrate);
element.addEventListener('astro:unmount', () => app.unmount(), { once: true });

View file

@ -19,7 +19,9 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) {
});
}
const app = createSSRApp({ render: () => h(Component, props, slots) });
await setup(app);
if (typeof setup === 'function') {
await setup(app);
}
const html = await renderToString(app);
return { html };
}