Open graph #132
3 changed files with 29 additions and 18 deletions
41
speech.js
41
speech.js
|
@ -48,20 +48,8 @@ const hbs = expressHandlebars.create({
|
||||||
</script>`
|
</script>`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
addOpenGraph (title, url, type, source, mimeType) {
|
addOpenGraph (title, url, source, mimeType) {
|
||||||
if (type === 'image') {
|
if (mimeType === 'video/mp4') {
|
||||||
return new Handlebars.SafeString(
|
|
||||||
`<meta property="og:title" content="${title}"/>
|
|
||||||
<meta property="og:url" content="${url}" />
|
|
||||||
<meta property="og:site_name" content="Spee.ch" />
|
|
||||||
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
|
|
||||||
<meta property="og:image" content="${source}" />
|
|
||||||
<meta property="og:image:type" content="${mimeType}" />
|
|
||||||
<meta property="og:image:width" content="600" />
|
|
||||||
<meta property="og:image:height" content="315" />
|
|
||||||
<meta property="og:type" content="article" />`
|
|
||||||
);
|
|
||||||
} else if (type === 'video') {
|
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<meta property="og:title" content="${title}"/>
|
`<meta property="og:title" content="${title}"/>
|
||||||
<meta property="og:url" content="${url}" />
|
<meta property="og:url" content="${url}" />
|
||||||
|
@ -73,8 +61,33 @@ const hbs = expressHandlebars.create({
|
||||||
<meta property="og:image:height" content="315" />
|
<meta property="og:image:height" content="315" />
|
||||||
<meta property="og:type" content="video" />
|
<meta property="og:type" content="video" />
|
||||||
<meta property="og:video" content="${source}" />
|
<meta property="og:video" content="${source}" />
|
||||||
|
<meta property="og:video:secure_url" content="${source}" />
|
||||||
<meta property="og:video:type" content="${mimeType}" />`
|
<meta property="og:video:type" content="${mimeType}" />`
|
||||||
);
|
);
|
||||||
|
} else if (mimeType === 'image/gif') {
|
||||||
|
return new Handlebars.SafeString(
|
||||||
|
`<meta property="og:title" content="${title}"/>
|
||||||
|
<meta property="og:url" content="${url}" />
|
||||||
|
<meta property="og:site_name" content="Spee.ch" />
|
||||||
|
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
|
||||||
|
<meta property="og:image" content="${source}" />
|
||||||
|
<meta property="og:image:type" content="${mimeType}" />
|
||||||
|
<meta property="og:image:width" content="600" />
|
||||||
|
<meta property="og:image:height" content="315" />
|
||||||
|
<meta property="og:type" content="video.other" />`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new Handlebars.SafeString(
|
||||||
|
`<meta property="og:title" content="${title}"/>
|
||||||
|
<meta property="og:url" content="${url}" />
|
||||||
|
<meta property="og:site_name" content="Spee.ch" />
|
||||||
|
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
|
||||||
|
<meta property="og:image" content="${source}" />
|
||||||
|
<meta property="og:image:type" content="${mimeType}" />
|
||||||
|
<meta property="og:image:width" content="600" />
|
||||||
|
<meta property="og:image:height" content="315" />
|
||||||
|
<meta property="og:type" content="article" />`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addTwitterCard (assetType, source) {
|
addTwitterCard (assetType, source) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
|
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
|
||||||
<meta property="fb:app_id" content="1371961932852223">
|
<meta property="fb:app_id" content="1371961932852223">
|
||||||
{{{addTwitterCard openGraphInfo.type openGraphInfo.source}}}
|
{{{addTwitterCard openGraphInfo.type openGraphInfo.source}}}
|
||||||
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.type openGraphInfo.source fileInfo.fileType }}}
|
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{{ body }}}
|
{{{ body }}}
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
{{!--fallback--}}
|
{{!--fallback--}}
|
||||||
Your browser does not support the <code>video</code> element.
|
Your browser does not support the <code>video</code> element.
|
||||||
</video>
|
</video>
|
||||||
{{addOpenGraph fileInfo.name links.showUrl 'video' links.source fileInfo.fileType }}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{{fileInfo.fileName}}"/>
|
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{
|
||||||
{{addOpenGraph fileInfo.name links.showUrl 'image' links.source fileInfo.fileType }}
|
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue