- stage
- seedling
- planted
- 2026-11-10
- tags
- [astro]
seedling— A rough idea. Incomplete, possibly wrong.
Astro's content layer doesn't keep file order
Entries come back sorted by id. If order matters, record it yourself.
getCollection() returns entries in the order of the content store, which is keyed by id. For a file loader over a YAML list, that means the order in the file is lost.
The fix on /uses was a custom parser on the file() loader that adds each item’s index:
file('./src/content/uses.yaml', {
parser: (text) => parseYaml(text).map((item, order) => ({ ...item, order })),
});
Then sort by order after querying. Still to check: whether the glob loader has the same behaviour, and whether it’s documented anywhere. Related: Wiki-links and backlinks in Astro relies on the same store.
$ grep -rl "[[content-layer-order]]" ~ # linked from
(no matches) Nothing links here yet.