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: {
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() {
if (window.location.pathname === "/" || window.location.pathname.length == 0)
switch (this.getPreferenceString("homepage", "trending")) {

View file

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

View file

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