diff --git a/src/router/index.js b/src/router/index.js index c21b25d..5ba9189 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -31,13 +31,30 @@ const routes = [ component: SearchResultsView, props: route => ({ searchQuery: route.query.q - }) + }), + meta: { + title: (route) => route.query.q + } } ]; const router = createRouter({ history: createWebHistory(), routes -}) +}); -export default router \ No newline at end of file +// set page title +router.afterEach(to => { + const title = + typeof to.meta.title === 'function' + ? to.meta.title(to) + : to.meta.title; + + if (title) { + document.title = `${title} - Seekra`; + } else { + document.title = 'Seekra'; + }; +}); + +export default router; \ No newline at end of file