X-Git-Url: https://git.r.bdr.sh/rbdr/prompt/blobdiff_plain/38431710cfb1cc1ffd7297085d069be1328f083b..a4c6e02bd78b416f2ba18880d0b7cb3ed017393b:/src/lib/stores/prompt.js?ds=sidebyside diff --git a/src/lib/stores/prompt.js b/src/lib/stores/prompt.js index 59df711..d0dc629 100644 --- a/src/lib/stores/prompt.js +++ b/src/lib/stores/prompt.js @@ -2,22 +2,23 @@ import { readable } from 'svelte/store'; import { browser } from '$app/env'; const internals = { - kDataPrefix: 'http://localhost:3000/data/', + kHost: import.meta.env.VITE_PUBLIC_BASE_PATH || 'http://localhost:3000', + kDataPrefix: '/data/', kAdjectivesPath: '/adjectives.json', kNounsPath: '/nouns.json', async get(locale, path) { const shortLocale = locale.split('-')[0]; - const targetFile = internals.kDataPrefix + shortLocale + path; - const data = browser && sessionStorage.getItem(targetFile); + const targetFile = internals.kHost + internals.kDataPrefix + shortLocale + path; + const data = browser && localStorage.getItem(targetFile); if (data) { return JSON.parse(data); } let newData = await (await fetch(targetFile)).json(); - browser && sessionStorage.setItem(targetFile, JSON.stringify(newData)); + browser && localStorage.setItem(targetFile, JSON.stringify(newData)); return newData; },