#Document routes for different types of users
3 messages · Page 1 of 1 (latest)
Yes, it is possible to have several pages of documentation in Astro. You can utilize Astro's dynamic routing feature to create different pages for different types of users. For example, you can create a page src/pages/manuals/[userType].astro where userType becomes a parameter that you can access from inside the page. This way, when a Teacher clicks on the teacher manuals, only the documentation for teacher manuals will be displayed.
Here is an example of how you can specify dynamic route parameters in Astro:
---
// src/pages/manuals/[userType].astro
import { Astro } from 'astro';
let { userType } = Astro.request.params;
let manual = fetchManualForUserType(userType); // fetchManualForUserType is a hypothetical function that fetches the manual for the given user type
---
<html>
<head>
<title>{manual.title}</title>
</head>
<body>
<h1>{manual.title}</h1>
<p>{manual.content}</p>
</body>
</html>
In this example, userType becomes a parameter that you can access from inside the page. The fetchManualForUserType function is a hypothetical function that fetches the manual for the given user type. You would replace this with your own function or method of fetching the manual.
In Astro’s default static output mode, these pages are generated at build time, and so you must predetermine the list of userTypes that get a corresponding file. In SSR mode, a page will be generated on request for any route that matches.
For more information, you can refer to the Astro documentation on dynamic routes (https://docs.astro.build/en/guides/routing/#dynamic-routes).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@stoic gale kapa.ai is still learning and improving, please let us know how it did by reacting below