Add a local articles collection
Register a collection named articles with a schema and local sample data. This prepares content to query; you still build the article list and pages.
- Where to run it
- Your generated project root: the folder containing package.json and astro.config.mjs.
- Before you start
- A project created by this modular installer. The collection name articles must not conflict with your own source.
npm
npx @samline/astro add content --source local --collection articlespnpm
pnpm dlx @samline/astro add content --source local --collection articlesBun
bunx @samline/astro add content --source local --collection articlesWhat you get
src/content.config.ts registers articles. The example stores locale, a dictionary copy key, a date and a draft flag in JSON, with display text in the content dictionary. It works offline.
Files added or configured
src/content.config.ts
src/content/articles/
README.md
index.ts
data/Choose API, Strapi, Shopify or another service when content lives elsewhere. Those examples need your source schema, credentials and explicit activation.
What to do next
Open src/content/articles/README.md for the getCollection example. Query articles from your content section, resolve the sample copy key through the dictionary, then replace the example with your project’s content model.