Skip to content

Instantly share code, notes, and snippets.

@madsh93
Created December 1, 2021 10:36
Show Gist options
  • Save madsh93/d7a554903d78ebe853bca22f8559e715 to your computer and use it in GitHub Desktop.
Save madsh93/d7a554903d78ebe853bca22f8559e715 to your computer and use it in GitHub Desktop.
<script>
export default {
async fetch() {
const response = await fetch('https://beyond-apis.glitch.me/launch/api/v2/all').then((res) =>
res.json()
)
const data = response[0].results.find((obj) => obj.slug === this.$route.params.slug)
// If data is null or undefined, return 404
if (data == null) {
return this.$nuxt.error({ statusCode: 404, message: 'Could not find launches' })
} else {
this.launches = data
}
},
data() {
return {
launches: []
}
},
head() {
return {
title: 'Launches - LiftoffTv',
meta: [
// Basic meta tags
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
// Facebook
{ name: 'og:site _name', content: 'LiftoffTv' }, // using dynamic things in meta tags
{ name: 'og:title', content: this.launches.name + ' - LiftoffTv' },
{ name: 'og:description', content: this.launches.mission.description },
{ name: 'og:image', content: this.launches.image },
// Twitter
{ name: 'twitter:title', content: this.launches.name + ' - LiftoffTv' },
{ name: 'twitter:description', content: this.launches.mission.description },
{ name: 'twitter:image', content: this.launches.image },
{ name: 'twitter:card', content: 'summary_large_image' },
// SEO
{ name: 'title', content: this.launches.name + ' - LiftoffTv' },
{ name: 'description', content: this.launches.mission.description },
{
name: 'keywords',
content:
'rocket, launches, news, spaceflight, nasa, spacex, starship, astronomy, apod, liftoff, tv, space'
},
{ name: 'author', content: 'LiftoffTv' },
{ name: 'robots', content: 'index, follow' },
{ name: 'language', content: 'English' },
{ name: 'revisit-after', content: '1 days' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/static/favicon.png' },
{ rel: 'shortcut icon', type: 'image/x-icon', href: '/static/favicon.png' }
]
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment