import { renderToString as renderToString_ } from '@vue/server-renderer'; import { escapeInject, dangerouslySkipEscape } from 'vite-plugin-ssr/server'; import { createApp } from './app'; import { useUser } from '../stores/user'; import logoUrl from './logo.svg'; async function renderToString(app) { let err; // Workaround: renderToString_() swallows errors in production, see https://github.com/vuejs/core/issues/7876 app.config.errorHandler = (err_) => { // eslint-disable-line no-param-reassign err = err_; }; const appHtml = await renderToString_(app); if (err) { throw err; } return appHtml; } async function render(pageContext) { const appHtml = await renderToString(pageContext.app); // See https://vite-plugin-ssr.com/head const { documentProps } = pageContext.exports; const title = (documentProps && documentProps.title) || 'shack'; const desc = (documentProps && documentProps.description) || 'Shack'; const documentHtml = escapeInject`