Display meta tags (for Facebook, Twitter, etc.)
Social media, here we come!
This commit is contained in:
parent
bd90d5168a
commit
4c42364083
1 changed files with 39 additions and 0 deletions
|
@ -86,8 +86,46 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
bodyAttrs = "page-template"
|
bodyAttrs = "page-template"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let baseUrl = this.$static.metadata.siteUrl||this.$static.metadata.ghost.url
|
||||||
|
|
||||||
|
let meta = [
|
||||||
|
{ property: 'og:site_name', content: 'Snipette' },
|
||||||
|
{ property: 'og:type', content: 'article' },
|
||||||
|
{ property: 'og:title', content: this.thisPost.title },
|
||||||
|
{ property: 'og:description', content: this.thisPost.description },
|
||||||
|
{ property: 'og:url', content: baseUrl + this.thisPost.path },
|
||||||
|
{ property: 'og:image', content: changeUrls(this.thisPost.image) },
|
||||||
|
{ property: 'article:published_time', content: this.thisPost.date },
|
||||||
|
]
|
||||||
|
|
||||||
|
for (var i=0; i<this.thisPost.tags.length; i++) {
|
||||||
|
meta.push({ property: 'article:tag', content: this.thisPost.tags[i].title })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Admin.social_media && Admin.social_media.facebook) {
|
||||||
|
meta.push({ property: 'article:publisher', content: 'https://www.facebook.com/' + Admin.social_media.facebook })
|
||||||
|
}
|
||||||
|
|
||||||
|
meta = meta.concat([
|
||||||
|
{ property: 'twitter:card', content: 'summary_large_image' },
|
||||||
|
{ property: 'twitter:title', content: this.thisPost.title },
|
||||||
|
{ property: 'twitter:description', content: this.thisPost.description },
|
||||||
|
{ property: 'twitter:url', content: baseUrl + this.thisPost.path },
|
||||||
|
{ property: 'twitter:image', content: changeUrls(this.thisPost.image) },
|
||||||
|
{ property: 'twitter:label1', content: 'Written by' },
|
||||||
|
{ property: 'twitter:data1', content: this.thisPost.authors[0].name },
|
||||||
|
{ property: 'twitter:label2', content: 'Filed under' },
|
||||||
|
{ property: 'twitter:data2', content: this.thisPost.tags.map((t)=>{return t.title}).join(',') },
|
||||||
|
])
|
||||||
|
|
||||||
|
if (Admin.social_media && Admin.social_media.twitter) {
|
||||||
|
meta.push({ property: 'twitter:site', content: '@' + Admin.social_media.twitter })
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: this.$page.post ? this.$page.post.title : this.$page.page.title,
|
title: this.$page.post ? this.$page.post.title : this.$page.page.title,
|
||||||
|
meta: meta,
|
||||||
bodyAttrs: {
|
bodyAttrs: {
|
||||||
class: bodyAttrs
|
class: bodyAttrs
|
||||||
}
|
}
|
||||||
|
@ -184,6 +222,7 @@ export default {
|
||||||
<static-query>
|
<static-query>
|
||||||
query Metadata {
|
query Metadata {
|
||||||
metadata {
|
metadata {
|
||||||
|
siteUrl
|
||||||
ghost {
|
ghost {
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
|
|
Loading…
Reference in a new issue