Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be77c7c

Browse filesBrowse 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
Copy full SHA for be77c7c

File tree

Expand file treeCollapse file tree

3 files changed

+12
-8
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-8
lines changed

‎src/components/ItemView.vue

Copy file name to clipboardExpand all lines: src/components/ItemView.vue
+10-8Lines changed: 10 additions & 8 deletions
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

Copy file name to clipboardExpand all lines: src/components/NewsView.vue
+1Lines changed: 1 addition & 0 deletions
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

Copy file name to clipboardExpand all lines: src/components/UserView.vue
+1Lines changed: 1 addition & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.