Browse Source

use handlebars if statements in templating

pull/376/head
mrjvs 2 years ago
parent
commit
7d6d41fb48
  1. 9
      example.env
  2. 40
      index.html
  3. 2
      src/assets/opensearch.xml.hbs
  4. 6
      vite.config.ts

9
example.env

@ -1,5 +1,8 @@ @@ -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

40
index.html

@ -34,25 +34,27 @@ @@ -34,25 +34,27 @@
<title>movie-web</title>
<!-- OpenSearch -->
{{{ opensearch }}}
<!-- Google Sitelinks -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "https://movie-web.app/",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "https://movie-web.app/browse/{search_term_string}"
},
"query-input": "required name=search_term_string"
}
}
</script>
{{#if opensearchEnabled }}
<!-- OpenSearch -->
<link rel="search" type="application/opensearchdescription+xml" title="movie-web" href="/opensearch.xml">
<!-- Google Sitelinks -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "{{ routeDomain }}",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "{{ routeDomain }}/browse/?q={search_term_string}"
},
"query-input": "required name=search_term_string"
}
}
</script>
{{/if}}
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

2
src/assets/opensearch.xml.hbs

@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
<ShortName>movie-web</ShortName>
<Description>The place for your favorite movies &amp; shows</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template="{{ appdomain }}/browse/{searchTerms}" />
<Url type="text/html" template="{{ routeDomain }}/browse/?q={searchTerms}" />
</OpenSearchDescription>

6
vite.config.ts

@ -13,8 +13,10 @@ export default defineConfig(({ mode }) => { @@ -13,8 +13,10 @@ export default defineConfig(({ mode }) => {
plugins: [
handlebars({
vars: {
opensearch: env.VITE_OPENSEARCH_ENABLED ? '<link rel="search" type="application/opensearchdescription+xml" title="movie-web" href="src/assets/opensearch.xml">' : "",
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({

Loading…
Cancel
Save