Files
mealie/frontend/src/routes.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-01-08 17:09:03 -09:00
import HomePage from "./pages/HomePage";
import Page404 from "./pages/404Page";
import RecipePage from "./pages/RecipePage";
import RecipeNewPage from "./pages/RecipeNewPage";
import SettingsPage from "./pages/SettingsPage";
import MeaplPlanPage from "./pages/MealPlanPage";
import MealPlanThisWeekPage from "./pages/MealPlanThisWeekPage";
2020-12-24 16:37:38 -09:00
import api from "./api";
export const routes = [
2021-01-08 17:09:03 -09:00
{ path: "/", component: HomePage },
{ path: "/mealie", component: HomePage },
{ path: "/recipe/:recipe", component: RecipePage },
{ path: "/new/", component: RecipeNewPage },
{ path: "/settings/site", component: SettingsPage },
{ path: "/meal-plan/planner", component: MeaplPlanPage },
{ path: "/meal-plan/this-week", component: MealPlanThisWeekPage },
2020-12-24 16:37:38 -09:00
{
path: "/meal-plan/today",
2021-01-08 17:09:03 -09:00
beforeEnter: async (_to, _from, next) => {
2020-12-24 16:37:38 -09:00
await todaysMealRoute().then((redirect) => {
next(redirect);
});
},
},
{ path: "*", component: Page404 },
];
async function todaysMealRoute() {
const response = await api.mealPlans.today();
return "/recipe/" + response.data;
}