From 42c319702a637ce0181043b8fb3f2fbc2649f299 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 2 Jun 2021 22:36:45 +0200 Subject: [PATCH] conditionally add metatags only if site title is odysee --- static/index-web.html | 4 ---- web/src/html.js | 16 +++++++++++++--- web/webpack.config.js | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/static/index-web.html b/static/index-web.html index e14fbe694..b9ffe6fd2 100644 --- a/static/index-web.html +++ b/static/index-web.html @@ -62,10 +62,6 @@ } - - - - diff --git a/web/src/html.js b/web/src/html.js index 454c18c2f..f24da20cb 100644 --- a/web/src/html.js +++ b/web/src/html.js @@ -78,8 +78,18 @@ function buildOgMetadata(overrideOptions = {}) { return head; } -function buildBasicOgMetadata() { - const head = '' + buildOgMetadata() + ''; +function conditionallyAddPWA() { + let head = ''; + if (SITE_TITLE === 'Odysee') { + head += '' + head += '' + head += '' + } + return head; +} + +function buildBasicOgMetadataAndPWA() { + const head = '' + conditionallyAddPWA() + buildOgMetadata() + ''; return head; } @@ -306,4 +316,4 @@ async function getHtml(ctx) { return insertToHead(html, ogMetadata); } -module.exports = { insertToHead, buildBasicOgMetadata, getHtml }; +module.exports = { insertToHead, buildBasicOgMetadataAndPWA, getHtml }; diff --git a/web/webpack.config.js b/web/webpack.config.js index 5bab05a33..0fe07e390 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -8,7 +8,7 @@ const WriteFilePlugin = require('write-file-webpack-plugin'); const { DefinePlugin, ProvidePlugin } = require('webpack'); const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const { getJsBundleId } = require('./bundle-id.js'); -const { insertToHead, buildBasicOgMetadata } = require('./src/html'); +const { insertToHead, buildBasicOgMetadataAndPWA } = require('./src/html'); const { insertVariableXml, getOpenSearchXml } = require('./src/xml'); const CUSTOM_ROOT = path.resolve(__dirname, '../custom/'); @@ -27,7 +27,7 @@ const copyWebpackCommands = [ to: `${DIST_ROOT}/index.html`, // add javascript script to index.html, generate/insert metatags transform(content, path) { - return insertToHead(content.toString(), buildBasicOgMetadata()); + return insertToHead(content.toString(), buildBasicOgMetadataAndPWA()); }, force: true, },