Colocate modules with pages
🌱 This post is in the growth phase. It may still be useful as it grows up.
Colocate modules in pages directories
Put modules that share getter functions and types inside nested /pages
directories.
Astro has a “generation one” /pages
directory.
Every .astro
, .md
, and .mdx
file becomes a page on your site.
Unlike other gen 1 /pages
directories (like those in Next.js, pre App Directory), Astro doesn’t read .js
or .tsx
modules as pages.
This means you can colocate collection-type specific code there.
Here’s what mine look like, at the moment.
You may see immediate value you this. You may not. I’ll do my best to make the benefits clear in other patterns.