From 7d6d41fb480d14c6acbd440f3f4d3467cc7077f3 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Sun, 23 Jul 2023 12:18:20 +0200 Subject: [PATCH] use handlebars if statements in templating --- example.env | 9 ++++++--- index.html | 38 ++++++++++++++++++----------------- src/assets/opensearch.xml.hbs | 2 +- vite.config.ts | 6 ++++-- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/example.env b/example.env index 27e4f03d..38c690a5 100644 --- a/example.env +++ b/example.env @@ -1,5 +1,8 @@ -# make sure the cors proxy url does NOT have a slash at the end -VITE_CORS_PROXY_URL=... VITE_TMDB_READ_API_KEY=... VITE_OPENSEARCH_ENABLED=false -VITE_APP_DOMAIN="http://localhost:5173" + +# make sure the cors proxy url does NOT have a slash at the end +VITE_CORS_PROXY_URL=... + +# make sure the domain does NOT have a slash at the end +VITE_APP_DOMAIN=http://localhost:5173 diff --git a/index.html b/index.html index 543c3e95..5c674b2f 100644 --- a/index.html +++ b/index.html @@ -34,25 +34,27 @@ movie-web - - {{{ opensearch }}} + {{#if opensearchEnabled }} + + - - + + + {{/if}} diff --git a/src/assets/opensearch.xml.hbs b/src/assets/opensearch.xml.hbs index 3f188d6f..e0ce3a5a 100644 --- a/src/assets/opensearch.xml.hbs +++ b/src/assets/opensearch.xml.hbs @@ -2,5 +2,5 @@ movie-web The place for your favorite movies & shows UTF-8 - + diff --git a/vite.config.ts b/vite.config.ts index 61cfc6d1..ce5746ad 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,8 +13,10 @@ export default defineConfig(({ mode }) => { plugins: [ handlebars({ vars: { - opensearch: env.VITE_OPENSEARCH_ENABLED ? '' : "", - appdomain: env.VITE_APP_DOMAIN, + opensearchEnabled: env.VITE_OPENSEARCH_ENABLED === "true", + routeDomain: env.VITE_APP_DOMAIN + (env.VITE_NORMAL_ROUTER !== 'true' ? "/#" : ""), + domain: env.VITE_APP_DOMAIN, + env, }, }), react({