front/SvelteViewEngine: add isSsr local

This commit is contained in:
Alice Gaudon 2021-11-28 16:41:46 +01:00
parent c606379bcd
commit 9674fc87dd
3 changed files with 4 additions and 2 deletions

View File

@ -14,7 +14,7 @@
let countdown;
let validUntilDate = new Date(validUntil);
$: countdown = $locals.isPreRender ? '...' : Time.humanizeTimeTo(validUntilDate);
$: countdown = $locals.isSsr ? '...' : Time.humanizeTimeTo(validUntilDate);
onMount(() => {
const interval = setInterval(() => {

View File

@ -48,12 +48,14 @@ export default class SvelteViewEngine extends ViewEngine {
const rootTemplateFile = await this.resolveFileFromCanonicalNameOrFail('templates/svelte_template.html');
const rawOutput = await this.fileCache.get(rootTemplateFile, !config.get<boolean>('view.cache'));
locals.isSsr = true;
const {
head,
html,
css,
} = await this.renderSvelteSsr(canonicalViewName, locals);
locals.isSsr = false;
const serializedLocals = JSON.stringify(locals, (key, value) => {
if (key.startsWith('_') || typeof value === 'function') return undefined;
return value;

View File

@ -12,7 +12,7 @@
}
</style>
<div class="render-mode">{$locals.isPreRender ? 'SSR' : 'CSR'}</div>
<div class="render-mode">{$locals.isSsr ? 'SSR' : 'CSR'}</div>
<div class="data-table-container">
<table class="data-table">