aboutsummaryrefslogtreecommitdiff
path: root/data/js/vue-app.js
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-03-21 01:36:24 +0100
committerPaul Oliver <contact@pauloliver.dev>2026-04-03 18:50:51 +0200
commitbda5ad2ec9fa333c8200451496d6c251abbeee19 (patch)
tree52e15344f239a023d298ee9635e8c7c0c4fdf614 /data/js/vue-app.js
parent9f7e70904e6c0fa650323ac5e50ebf6003da333c (diff)
Adds data server (WIP)
Diffstat (limited to 'data/js/vue-app.js')
-rw-r--r--data/js/vue-app.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/data/js/vue-app.js b/data/js/vue-app.js
new file mode 100644
index 0000000..80a813f
--- /dev/null
+++ b/data/js/vue-app.js
@@ -0,0 +1,24 @@
+const { createApp } = Vue
+const { loadModule } = window['vue3-sfc-loader']
+
+const addStyle = styleStr => {
+ const style = document.createElement('style')
+ const ref = document.head.getElementsByTagName('style')[0] || null
+ style.textContent = styleStr
+ document.head.insertBefore(style, ref)
+}
+
+const getFile = url => fetch(url).then(resp => resp.ok ? resp.text() : Promise.reject(resp))
+const moduleCache = { vue: Vue }
+
+const options = { addStyle, getFile, moduleCache }
+
+const app = createApp({
+ components: {
+ App: Vue.defineAsyncComponent(() => loadModule('vue/App.vue', options)),
+ Section: Vue.defineAsyncComponent(() => loadModule('vue/Section.vue', options)),
+ Plot: Vue.defineAsyncComponent(() => loadModule('vue/Plot.vue', options)),
+ },
+})
+
+app.mount('#app')