Astro is a static-site generator.
It uses a template language .astro
, which is kind of similar to jsx, though it separates a JavaScript-based “header” and the markup.
Subtopics
Upgrade Astro
To upgrade Astro, we need to upgrade its integrations too
npm install astro@latest
# Example: upgrade the blog tutorial Preact integration
npm install @astrojs/preact@latest
Getting markdown pages
e.g.
const allPosts = await Astro.glob('../pages/posts/*.md');
For collections we need to use getCollection
instead
import { getCollection } from "astro:content";
const allPosts = await getCollection("posts");
getStaticPaths
function
returns an array of page routes
Used to generate multiple pages from a same file