Skip to content

Commit be77c7c

Browse files
author
Dan Hersam
committed
Show the title on item and user pages.
Would be nice to avoid duplicating the 'Vue.js HN Clone' string, but I didn't find a clean way.
1 parent 190eecf commit be77c7c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/components/ItemView.vue

+10-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ export default {
4242
4343
route: {
4444
data ({ to }) {
45-
return store.fetchItem(to.params.id).then(item => ({
46-
item,
47-
// the final resolved data can further contain Promises
48-
comments: store.fetchItems(item.kids),
49-
pollOptions: item.type === 'poll'
50-
? store.fetchItems(item.parts)
51-
: null
52-
}))
45+
return store.fetchItem(to.params.id).then(item => {
46+
document.title = item.title + ' | Vue.js HN Clone'
47+
return {
48+
item,
49+
// the final resolved data can further contain Promises
50+
comments: store.fetchItems(item.kids),
51+
pollOptions: item.type === 'poll'
52+
? store.fetchItems(item.parts)
53+
: null
54+
}})
5355
}
5456
},
5557

src/components/NewsView.vue

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default {
5050
// the entire object, because we don't want to update the page before
5151
// the items are fetched.
5252
const page = +to.params.page
53+
document.title = 'Vue.js HN Clone'
5354
return store.fetchItemsByPage(page).then(items => ({
5455
page,
5556
items

src/components/UserView.vue

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
data ({ to }) {
3636
// Promise sugar syntax: return an object that contains Promise fields.
3737
// http://router.vuejs.org/en/pipeline/data.html#promise-sugar
38+
document.title = 'Profile: ' + to.params.id + ' | Vue.js HN Clone'
3839
return {
3940
user: store.fetchUser(to.params.id)
4041
}

0 commit comments

Comments
 (0)