diff --git a/README.md b/README.md index fcd3ebe..ab10d5d 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,12 @@ VITE_PASSWORD=your-private-password ### Creating a page -Templates are managed through Vue (`/src/views`). Thus, the process for creating new pages differs from the Kirby usual one. In addition to the **blueprint** (`/public/site/blueprints/pages/example.yml`) and **template** (`/public/site/templates/example.php`) files, it needs at least a **content representation** (`/public/site/templates/example.json.php`) and a **view component** (`/src/views/Example.vue`) ones. +Templates are managed through Vue (`/src/views`). Thus, the process for creating new pages differs from the Kirby usual one. In addition to the **blueprint** (`/public/site/blueprints/pages/example.yml`) and **template** (`/public/site/templates/example.php`) files and the corresponding content directory (`/public/content// - ``` -5. **Import the view** in the `/src/App.vue` root component : +5. **Create the route** in the `/src/router/routes.js`. A route is a combination of a path and a corresponding component. The path can include variable parameters, which can be captured and passed to the component. To create a route, you need to import the component and add an object to the routes array. See the [Vue Router documentation](https://router.vuejs.org/guide/) for more information. ```vue ``` diff --git a/src/router/router.js b/src/router/router.js index c6b2f03..79fb91f 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -1,36 +1,9 @@ import { createWebHistory, createRouter } from "vue-router"; -import Home from "../views/Home.vue"; -import Notifications from "../views/Notifications.vue"; -import Reunions from "../views/Reunions.vue"; -import Inspirations from "../views/Inspirations.vue"; -import Project from "../views/Project.vue"; +import routes from "./routes"; import { useApiStore } from "../stores/api"; import { usePageStore } from "../stores/page"; import { getActivePinia } from "pinia"; -const routes = [ - { - path: "/", - component: Home, - }, - { - path: "/notifications", - component: Notifications, - }, - { - path: "/reunions", - component: Reunions, - }, - { - path: "/inspirations", - component: Inspirations, - }, - { - path: "/projects/:id", - component: Project, - }, -]; - const router = createRouter({ history: createWebHistory(), routes, diff --git a/src/router/routes.js b/src/router/routes.js new file mode 100644 index 0000000..e2cee27 --- /dev/null +++ b/src/router/routes.js @@ -0,0 +1,30 @@ +import Home from "../views/Home.vue"; +import Notifications from "../views/Notifications.vue"; +import Reunions from "../views/Reunions.vue"; +import Inspirations from "../views/Inspirations.vue"; +import Project from "../views/Project.vue"; + +const routes = [ + { + path: "/", + component: Home, + }, + { + path: "/notifications", + component: Notifications, + }, + { + path: "/reunions", + component: Reunions, + }, + { + path: "/inspirations", + component: Inspirations, + }, + { + path: "/projects/:id", + component: Project, + }, +]; + +export default routes; diff --git a/src/views/Example.vue b/src/views/Example.vue index 06edc1d..58d7bd2 100644 --- a/src/views/Example.vue +++ b/src/views/Example.vue @@ -1,16 +1,12 @@ - - + +