--- import { getCollection } from "astro:content"; const allFragments = await getCollection("fragment"); const maxLength = Math.max(2, String(allFragments.length - 1).length); --- Fragments { allFragments.map((f, ix) => { const paddedIndex = String(ix).padStart(maxLength, "0"); return {paddedIndex}; }) }