From aad60b9db50b79648f9ff89dd9ade5a02a3a9a4c Mon Sep 17 00:00:00 2001 From: Karlis Cudars Date: Wed, 21 Jul 2021 01:16:17 +0300 Subject: [PATCH] Watch for route changes and change page title according to new route --- src/App.vue | 16 ++++++++++++++++ src/components/FeedPage.vue | 2 -- src/components/TrendingPage.vue | 2 -- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4e74b80b..26ca267b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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")) { diff --git a/src/components/FeedPage.vue b/src/components/FeedPage.vue index 5b95ce8e..cda4ad66 100644 --- a/src/components/FeedPage.vue +++ b/src/components/FeedPage.vue @@ -63,8 +63,6 @@ export default { }; }, mounted() { - document.title = "Feed - Piped"; - this.fetchFeed().then(videos => (this.videos = videos)); }, methods: { diff --git a/src/components/TrendingPage.vue b/src/components/TrendingPage.vue index 42b9b9de..04e1a581 100644 --- a/src/components/TrendingPage.vue +++ b/src/components/TrendingPage.vue @@ -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));