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

@@ -8,6 +8,7 @@ import ManageUsers from "@/pages/Admin/ManageUsers";
import Settings from "@/pages/Admin/Settings";
import About from "@/pages/Admin/About";
import { store } from "../store";
import i18n from '@/i18n.js';
export default {
path: "/admin",
@@ -25,35 +26,59 @@ export default {
{
path: "profile",
component: Profile,
meta: {
title: i18n.t('settings.profile'),
},
},
{
path: "backups",
component: Backup,
meta: {
title: i18n.t('settings.backup-and-exports'),
},
},
{
path: "themes",
component: Theme,
meta: {
title: i18n.t('general.themes'),
},
},
{
path: "meal-planner",
component: MealPlanner,
meta: {
title: i18n.t('meal-plan.meal-planner'),
},
},
{
path: "migrations",
component: Migration,
meta: {
title: i18n.t('settings.migrations'),
},
},
{
path: "manage-users",
component: ManageUsers,
meta: {
title: i18n.t('settings.manage-users'),
},
},
{
path: "settings",
component: Settings,
meta: {
title: i18n.t('settings.site-settings'),
},
},
{
path: "about",
component: About,
meta: {
title: i18n.t('general.about'),
},
},
],
};

View File

@@ -15,6 +15,7 @@ import ThisWeek from "@/pages/MealPlan/ThisWeek";
import { api } from "@/api";
import Admin from "./admin";
import { store } from "../store";
import i18n from '@/i18n.js';
export const routes = [
{ path: "/", name: "home", component: HomePage },
@@ -31,15 +32,43 @@ export const routes = [
{ path: "/sign-up", redirect: "/" },
{ path: "/sign-up/:token", component: SignUpPage },
{ path: "/debug", component: Debug },
{ path: "/search", component: SearchPage },
{
path: "/search",
component: SearchPage,
meta: {
title: i18n.t('search.search'),
},
},
{ path: "/recipes/all", component: AllRecipes },
{ path: "/pages/:customPage", component: CustomPage },
{ path: "/recipes/tag/:tag", component: TagPage },
{ path: "/recipes/category/:category", component: CategoryPage },
{ path: "/recipe/:recipe", component: ViewRecipe },
{
path: "/recipe/:recipe",
component: ViewRecipe,
meta: {
title: async route => {
const recipe = await api.recipes.requestDetails(route.params.recipe);
return recipe.name;
},
}
},
{ path: "/new/", component: NewRecipe },
{ path: "/meal-plan/planner", component: Planner },
{ path: "/meal-plan/this-week", component: ThisWeek },
{
path: "/meal-plan/planner",
component: Planner,
meta: {
title: i18n.t('meal-plan.meal-planner'),
}
},
{
path: "/meal-plan/this-week",
component: ThisWeek,
meta: {
title: i18n.t('meal-plan.dinner-this-week'),
}
},
Admin,
{
path: "/meal-plan/today",