diff --git a/helpers/handlebarsHelpers.js b/helpers/handlebarsHelpers.js index fec9ace6..59275e0c 100644 --- a/helpers/handlebarsHelpers.js +++ b/helpers/handlebarsHelpers.js @@ -2,41 +2,40 @@ const Handlebars = require('handlebars'); const config = require('../config/speechConfig.js'); module.exports = { - // define any extra helpers you may need googleAnalytics () { const googleApiKey = config.analytics.googleId; - return new Handlebars.SafeString( - `` - ); + ga('send', 'pageview');`; + return new Handlebars.SafeString(gaCode); }, addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) { - console.log('title', title); - console.log('description', description); - let ogTitle = ``; - let ogUrl = ``; - let ogSiteName = ``; - let ogDescription = ``; - let ogImageWidth = ''; - let ogImageHeight = ''; - let basicTags = `${ogTitle} ${ogUrl} ${ogSiteName} ${ogDescription} ${ogImageWidth} ${ogImageHeight}`; + if (title === null || title.trim() === '') { + title = 'Spee.ch'; + } + if (description === null || description.trim() === '') { + description = 'Open-source, decentralized image and video sharing.'; + } + const ogTitle = ``; + const ogUrl = ``; + const ogSiteName = ``; + const ogDescription = ``; + const ogImageWidth = ''; + const ogImageHeight = ''; + const basicTags = `${ogTitle} ${ogUrl} ${ogSiteName} ${ogDescription} ${ogImageWidth} ${ogImageHeight}`; let ogImage = ``; let ogImageType = ``; let ogType = ``; if (mimeType === 'video/mp4') { - let ogVideo, ogVideoSecureUrl, ogVideoType; + const ogVideo = ``; + const ogVideoSecureUrl = ``; + const ogVideoType = ``; ogImage = ``; ogImageType = ``; ogType = ``; - ogVideo = ``; - ogVideoSecureUrl = ``; - ogVideoType = ``; return new Handlebars.SafeString(`${basicTags} ${ogImage} ${ogImageType} ${ogType} ${ogVideo} ${ogVideoSecureUrl} ${ogVideoType}`); } else { if (mimeType === 'image/gif') { @@ -46,18 +45,18 @@ module.exports = { } }, addTwitterCard (mimeType, source, embedUrl, directFileUrl) { - let basicTwitterTags = ``; + const basicTwitterTags = ``; if (mimeType === 'video/mp4') { - let twitterName = ''; - let twitterPlayer = ``; - let twitterPlayerWidth = ''; - let twitterTextPlayerWidth = ''; - let twitterPlayerHeight = ''; - let twitterPlayerStream = ``; - let twitterPlayerStreamContentType = ''; + const twitterName = ''; + const twitterPlayer = ``; + const twitterPlayerWidth = ''; + const twitterTextPlayerWidth = ''; + const twitterPlayerHeight = ''; + const twitterPlayerStream = ``; + const twitterPlayerStreamContentType = ''; return new Handlebars.SafeString(`${basicTwitterTags} ${twitterName} ${twitterPlayer} ${twitterPlayerWidth} ${twitterTextPlayerWidth} ${twitterPlayerHeight} ${twitterPlayerStream} ${twitterPlayerStreamContentType}`); } else { - let twitterCard = ''; + const twitterCard = ''; return new Handlebars.SafeString(`${basicTwitterTags} ${twitterCard}`); } },