b0ee81d0a7
* fix: add __ssrInlineRender to Vue check * chore: remove console log * test: vue builds with other renderer present * chore: changeset
22 lines
656 B
JavaScript
22 lines
656 B
JavaScript
import { h, createSSRApp } from 'vue';
|
|
import { renderToString } from 'vue/server-renderer';
|
|
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) });
|
|
const html = await renderToString(app);
|
|
return { html };
|
|
}
|
|
|
|
export default {
|
|
check,
|
|
renderToStaticMarkup,
|
|
};
|