mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/version: don't try to fetch when server-side rendering
This commit is contained in:
parent
f009da7de4
commit
1262bc20fe
1 changed files with 3 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { readable } from "svelte/store";
|
import { readable } from "svelte/store";
|
||||||
import type { Optional } from "./types/generic";
|
import type { Optional } from "./types/generic";
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
type VersionResponse = {
|
type VersionResponse = {
|
||||||
commit: string;
|
commit: string;
|
||||||
|
@ -11,6 +12,8 @@ type VersionResponse = {
|
||||||
export const version = readable<Optional<VersionResponse>>(
|
export const version = readable<Optional<VersionResponse>>(
|
||||||
undefined,
|
undefined,
|
||||||
(set) => {
|
(set) => {
|
||||||
|
if (!browser) return;
|
||||||
|
|
||||||
fetch('/version.json')
|
fetch('/version.json')
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(set)
|
.then(set)
|
||||||
|
|
Loading…
Reference in a new issue