Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i create a new route ? #24

Closed
houmedfa opened this issue Sep 3, 2022 · 2 comments
Closed

how can i create a new route ? #24

houmedfa opened this issue Sep 3, 2022 · 2 comments

Comments

@houmedfa
Copy link

houmedfa commented Sep 3, 2022

hi, i just discover and fork this repo. i think "astrowind" is the best solution for landing and blog post static website.

i want to create a new routes "/organisations"

│ ├── pages/
│ | ├── [...blog]/
| | ├── [...page].astro
| | └── [slug].astro
│ | ├── [...organisations]/
| | ├── [...page].astro
| | └── [slug].astro

when i created these files and trying to check the route . i have a error .
" getstaticPaths route pattern matched but no matching static path found (/organisations)

thank for your anwser .

@prototypa
Copy link
Contributor

Hi @houmedfa

It's good to know that you find AstroWind useful. It is still a work in progress, any suggestion or idea you have, contact us.

The error that is shown to you is because you are defining the route like this [...organizations]. According to the Astro documentation, routes defined with [] are dynamic and require you to implement the getStaticPaths function.

My doubt is that I don't know if you need to create only one page with /organizations, or a list of dynamic pages inside the organizations folder

  1. To create the '/organizations' url, if you only want to create that route with a simple page you can do either of the two variants:

A

/
│   ├── pages/
│   |   ├── ...
│   |   ├── [...blog]/
|   |   |   ├── [...page].astro
|   |   |   └── [slug].astro
+   |   ├── organizations/
+   |   |   └── index.astro
│   |   ├── index.astro
|   |   ├── 404.astro
|   |   └-- rss.xml.js
└── ...

B

/
│   ├── pages/
│   |   ├── ...
│   |   ├── [...blog]/
|   |   |   ├── [...page].astro
|   |   |   └── [slug].astro
+   |   ├── organizations.astro
│   |   ├── index.astro
|   |   ├── 404.astro
|   |   └-- rss.xml.js
└── ...

2. On the other hand, if you want to create a list of pages inside /organizations route, then the folder structure for the paths should be different.
/
│   ├── pages/
│   |   ├── ...
│   |   ├── [...blog]/
|   |   |   ├── [...page].astro
|   |   |   └── [slug].astro
+   |   ├── organizations/
+   |   |   ├── organization1.astro
+   |   |   ├── organization2.astro
+   |   |   └── index.astro
│   |   ├── index.astro
|   |   ├── 404.astro
|   |   └-- rss.xml.js
└── ...

3. And if you want to create a list of **dynamic pages** inside /organizations route, then the folder structure for the paths should be different.
/
│   ├── pages/
│   |   ├── ...
│   |   ├── [...blog]/
|   |   |   ├── [...page].astro
|   |   |   └── [slug].astro
+   |   ├── organizations/
+   |   |   ├── [...pages].astro
+   |   |   └──[slug].astro
│   |   ├── index.astro
|   |   ├── 404.astro
|   |   └-- rss.xml.js
└── ...

And you should also implement a getStaticPaths function inside each of those dynamic paths [slug].astro, [...page].astro

https://docs.astro.build/en/core-concepts/routing/#dynamic-routes

@houmedfa
Copy link
Author

houmedfa commented Sep 4, 2022

thank you for your clean and helpful anwser.

@houmedfa houmedfa closed this as completed Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants