Skip to content

Commit

Permalink
Meta tags for social media previews
Browse files Browse the repository at this point in the history
  • Loading branch information
AtanasKrondev committed Jun 14, 2021
1 parent 02a8ab6 commit d945ae0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/views/TipsAndComments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import BackButtonRibbon from '../components/BackButtonRibbon.vue';
import Loading from '../components/Loading.vue';
import backendAuthMixin from '../utils/backendAuthMixin';
import SendComment from '../components/SendComment.vue';
import Backend from '../utils/backend';
export default {
components: {
Expand Down Expand Up @@ -124,7 +125,26 @@ export default {
tip: 'Comments for a Tip',
comment: 'Comment View',
}[this.$route.name];
return { title };
const author = this.id ? this.record?.author : this.record?.sender;
const avatar = Backend.getProfileImageUrl(author);
const ogImage = this.record?.media?.length ? this.record.media[0] : avatar;
const ogUrl = window.location.href.split('?')[0];
const ogTitle = `Superhero ${this.id ? 'Comment' : `Tip ${this.tipId.split('_')[1]}`}`;
const ogDescription = this.id ? this.record?.text : this.record?.title;
const meta = [
{ property: 'og:image', content: ogImage },
{ property: 'og:url', content: ogUrl },
{ property: 'og:title', content: ogTitle },
{ property: 'og:description', content: ogDescription },
{ property: 'og:site_name', content: 'Superhero' },
{ name: 'twitter:card', content: 'summary' },
{ name: 'twitter:site', content: '@superhero_chain' },
{ name: 'twitter:creator', content: '@superhero_chain' },
{ name: 'twitter:image:alt', content: 'Superhero post' },
];
return { title, meta };
},
};
</script>
Expand Down

0 comments on commit d945ae0

Please sign in to comment.