Enrich page title with context (#296)

- Static pages have their own titles
- The name of the recipe is displayed when viewing it
This commit is contained in:
sephrat
2021-04-14 17:12:22 +02:00
committed by GitHub
parent 2c3fa81227
commit f3ea467e20
6 changed files with 81 additions and 9 deletions

View File

@@ -18,6 +18,20 @@ const router = new VueRouter({
mode: process.env.NODE_ENV === "production" ? "history" : "hash",
});
const DEFAULT_TITLE = 'Mealie';
const TITLE_SEPARATOR = '🍴';
const TITLE_SUFFIX = " " + TITLE_SEPARATOR + " " + DEFAULT_TITLE;
router.afterEach( (to) => {
Vue.nextTick( async () => {
if(typeof to.meta.title === 'function' ) {
const title = await to.meta.title(to);
document.title = title + TITLE_SUFFIX;
} else {
document.title = to.meta.title ? to.meta.title + TITLE_SUFFIX : DEFAULT_TITLE;
}
});
});
const vueApp = new Vue({
vuetify,
store,