astro-dev-only-routes v0.0.2
Table of contents
Why astro-dev-only-routes?
Astro is a great tool for building static websites. However, it doesn't have a way to make some routes only available in dev mode, which could be useful for testing purposes, dashboards, design systems, etc.
astro-dev-only-routes is an Astro integration that allows you to make some routes only available in dev mode.
Many Thanks to all the Stargazers
π Demo
Try out the minimal demo.
π» Quickstart
To get started, you can install astro-dev-only-routes with the astro add CLI tool
# Using NPM
npx astro add astro-dev-only-routes
# Using YARN
yarn astro add astro-dev-only-routes
# Using PNPM
pnpm astro add astro-dev-only-routesNow that you have installed the integration, you can add dev-only routes by prefixing the route with double underscores (__).
Create a new file in the src/pages directory and name it __secret-panel.astro. This page will only be available in dev mode.
// src/pages/__secret-panel.astro
---
console.log('This page is only available in dev mode.')
---
<h1>Secret Page</h1>
<p> This page is only available in dev mode. </p>That's it! Now you can run astro dev and navigate to http://localhost:3000/__secret-page to see the page.
Try running astro build and you will see that the page is not included in the build.
π Known Issues
index.astroroutes need to be reference with theindexpart instead of just/. It's technically possible to fix that but there's a bug in Astro that maskes the fix cause those routes to collide with the rootindex.astroroute, even though that's not the case. Gonna open an issue for that.
πΊοΈ Roadmap
This is what's planned for the future. If you have any suggestions, please open an issue.
- Create a proposal for Astro to add this feature natively.
π‘οΈ License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support
If you liked this project, please give it a βοΈ. That's the best way you can support it!
3 years ago