Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit 7b627d3

Browse files
authored
Merge pull request #5 from hisasann/feature/add-async-custom-head
feat: add async custom head
2 parents 9166aad + 5e9b068 commit 7b627d3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template lang="pug">
2+
section.container
3+
h1.title
4+
| custom-head
5+
</template>
6+
7+
<script lang="ts">
8+
import { Component, Vue } from 'nuxt-property-decorator'
9+
10+
@Component
11+
export default class extends Vue {
12+
public title: string = ''
13+
public content: string = ''
14+
15+
public asyncData() {
16+
return {
17+
content: 'from asyncData'
18+
}
19+
}
20+
public data() {
21+
return {
22+
title: 'custom-head'
23+
}
24+
}
25+
26+
public head() {
27+
const robots = {
28+
name: 'robots',
29+
content: `noindex,nofollow`
30+
}
31+
32+
return {
33+
title: this.title,
34+
meta: [
35+
{
36+
hid: 'description',
37+
name: 'description',
38+
content: `My custom description ${this.content}`
39+
},
40+
robots
41+
]
42+
}
43+
}
44+
}
45+
</script>

src/pages/example/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
p
3333
nuxt-link(to='/example/custom-head', no-prefetch)
3434
| custom-head
35+
p
36+
nuxt-link(to='/example/async-custom-head', no-prefetch)
37+
| async-custom-head
3538
p
3639
nuxt-link(to='/example/api')
3740
| api

0 commit comments

Comments
 (0)