Skip to content

Commit

Permalink
feat(SEO): show canonical route and use API for og image
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 3, 2022
1 parent e4b89c3 commit a554379
Showing 1 changed file with 69 additions and 14 deletions.
83 changes: 69 additions & 14 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
},
head() {
const head = {
const HEAD = {
meta: [
// Necessary so images can be loaded from other domains
{
Expand All @@ -88,30 +88,85 @@ export default {
}
// Join array of tags into a comma separated string
const tags = SeoHelper.tagArrayToTitle(this.getTags)
const TAGS = SeoHelper.tagArrayToTitle(this.getTags)
if (tags) {
if (TAGS) {
// Title
head.title = tags + ' Hentai Porn'
const TITLE = TAGS + ' Hentai Porn'
HEAD.title = TITLE
HEAD.meta.push({
hid: 'og:title',
name: 'og:title',
content: TITLE
})
// Description
head.meta.push({
const DESCRIPTION = `Browse popular ${TAGS} Rule 34 Hentai Porn for free. Without ads.`
HEAD.meta.push({
hid: 'description',
name: 'description',
content: `Browse popular ${ tags } Rule 34 Hentai Porn for free. Without ads.`
content: DESCRIPTION
})
// Canonical
const CANONICAL_ROUTE = RouterHelper.generatePostsRouteWithDefaults(this.$nuxt.$store, undefined, undefined, this.getTags)
head.link.push({
hid: 'canonical',
name: 'canonical',
content: this.$router.resolve(CANONICAL_ROUTE).href
HEAD.meta.push({
hid: 'og:description',
name: 'og:description',
content: DESCRIPTION
})
}
return head
// Canonical
const CANONICAL_ROUTE = RouterHelper.generatePostsRouteWithDefaults(
this.$nuxt.$store,
undefined,
undefined,
this.getTags
)
const RESOLVED_CANONICAL_ROUTE = this.$router.resolve(CANONICAL_ROUTE)
const ABSOLUTE_URL = new URL(
RESOLVED_CANONICAL_ROUTE.href,
window.location.origin
).href
HEAD.link.push({
hid: 'canonical',
name: 'canonical',
content: RESOLVED_CANONICAL_ROUTE.href
})
// OG Image
HEAD.meta.push({
hid: 'og:image',
name: 'og:image',
content: `https://url-shot.api-point.cf/?width=1200&height=630&url=${encodeURI(
ABSOLUTE_URL
)}`
})
HEAD.meta.push({
hid: 'og:image:width',
name: 'og:image:width',
content: 1200
})
HEAD.meta.push({
hid: 'og:image:height',
name: 'og:image:height',
content: 630
})
HEAD.meta.push({
hid: 'og:image:type',
name: 'og:image:type',
content: 'image/png'
})
return HEAD
},
computed: {
Expand Down

0 comments on commit a554379

Please sign in to comment.