conditionally add metatags only if site title is odysee

This commit is contained in:
Anthony 2021-06-02 22:36:45 +02:00 committed by Jeremy Kauffman
parent 304bb3a999
commit 42c319702a
3 changed files with 15 additions and 9 deletions

View file

@ -62,10 +62,6 @@
} }
</style> </style>
<link rel="manifest" href="./public/pwa/manifest.json"/>
<link rel="apple-touch-icon" sizes="180x180" href="./public/pwa/icon-180.png">
<script src="./serviceWorker.js"></script>
<!-- VARIABLE_HEAD_BEGIN --> <!-- VARIABLE_HEAD_BEGIN -->
<!-- VARIABLE_HEAD_END --> <!-- VARIABLE_HEAD_END -->
</head> </head>

View file

@ -78,8 +78,18 @@ function buildOgMetadata(overrideOptions = {}) {
return head; return head;
} }
function buildBasicOgMetadata() { function conditionallyAddPWA() {
const head = '<!-- VARIABLE_HEAD_BEGIN -->' + buildOgMetadata() + '<!-- VARIABLE_HEAD_END -->'; let head = '';
if (SITE_TITLE === 'Odysee') {
head += '<link rel="manifest" href="./public/pwa/manifest.json"/>'
head += '<link rel="apple-touch-icon" sizes="180x180" href="./public/pwa/icon-180.png">'
head += '<script src="./serviceWorker.js"></script>'
}
return head;
}
function buildBasicOgMetadataAndPWA() {
const head = '<!-- VARIABLE_HEAD_BEGIN -->' + conditionallyAddPWA() + buildOgMetadata() + '<!-- VARIABLE_HEAD_END -->';
return head; return head;
} }
@ -306,4 +316,4 @@ async function getHtml(ctx) {
return insertToHead(html, ogMetadata); return insertToHead(html, ogMetadata);
} }
module.exports = { insertToHead, buildBasicOgMetadata, getHtml }; module.exports = { insertToHead, buildBasicOgMetadataAndPWA, getHtml };

View file

@ -8,7 +8,7 @@ const WriteFilePlugin = require('write-file-webpack-plugin');
const { DefinePlugin, ProvidePlugin } = require('webpack'); const { DefinePlugin, ProvidePlugin } = require('webpack');
const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const { getJsBundleId } = require('./bundle-id.js'); 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 { insertVariableXml, getOpenSearchXml } = require('./src/xml');
const CUSTOM_ROOT = path.resolve(__dirname, '../custom/'); const CUSTOM_ROOT = path.resolve(__dirname, '../custom/');
@ -27,7 +27,7 @@ const copyWebpackCommands = [
to: `${DIST_ROOT}/index.html`, to: `${DIST_ROOT}/index.html`,
// add javascript script to index.html, generate/insert metatags // add javascript script to index.html, generate/insert metatags
transform(content, path) { transform(content, path) {
return insertToHead(content.toString(), buildBasicOgMetadata()); return insertToHead(content.toString(), buildBasicOgMetadataAndPWA());
}, },
force: true, force: true,
}, },