Watch for route changes and change page title according to new route

This commit is contained in:
Karlis Cudars 2021-07-21 01:16:17 +03:00
parent b9f401cd39
commit aad60b9db5
3 changed files with 16 additions and 4 deletions

View file

@ -30,6 +30,22 @@ export default {
components: { components: {
Navigation, Navigation,
}, },
watch: {
$route: {
immediate: true,
handler(to) {
switch(to.path) {
case "/feed":
document.title = "Feed - Piped";
break;
case "/":
document.title = "Trending - Piped";
break;
default:
}
}
},
},
mounted() { mounted() {
if (window.location.pathname === "/" || window.location.pathname.length == 0) if (window.location.pathname === "/" || window.location.pathname.length == 0)
switch (this.getPreferenceString("homepage", "trending")) { switch (this.getPreferenceString("homepage", "trending")) {

View file

@ -63,8 +63,6 @@ export default {
}; };
}, },
mounted() { mounted() {
document.title = "Feed - Piped";
this.fetchFeed().then(videos => (this.videos = videos)); this.fetchFeed().then(videos => (this.videos = videos));
}, },
methods: { methods: {

View file

@ -25,8 +25,6 @@ export default {
}; };
}, },
mounted() { mounted() {
document.title = "Trending - Piped";
let region = this.getPreferenceString("region", "US"); let region = this.getPreferenceString("region", "US");
this.fetchTrending(region).then(videos => (this.videos = videos)); this.fetchTrending(region).then(videos => (this.videos = videos));