chore: improve app setup call
This commit is contained in:
parent
9cd6a6657b
commit
ee5d84a665
2 changed files with 6 additions and 2 deletions
|
@ -24,7 +24,9 @@ export default (element) =>
|
||||||
const isHydrate = client !== 'only';
|
const isHydrate = client !== 'only';
|
||||||
const boostrap = isHydrate ? createSSRApp : createApp;
|
const boostrap = isHydrate ? createSSRApp : createApp;
|
||||||
const app = boostrap({ name, render: () => content });
|
const app = boostrap({ name, render: () => content });
|
||||||
|
if (typeof setup === 'function') {
|
||||||
await setup(app);
|
await setup(app);
|
||||||
|
}
|
||||||
app.mount(element, isHydrate);
|
app.mount(element, isHydrate);
|
||||||
|
|
||||||
element.addEventListener('astro:unmount', () => app.unmount(), { once: true });
|
element.addEventListener('astro:unmount', () => app.unmount(), { once: true });
|
||||||
|
|
|
@ -19,7 +19,9 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
||||||
|
if (typeof setup === 'function') {
|
||||||
await setup(app);
|
await setup(app);
|
||||||
|
}
|
||||||
const html = await renderToString(app);
|
const html = await renderToString(app);
|
||||||
return { html };
|
return { html };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue