
Nov 1, 2026 · 1 min read
This entry has no Spanish translation, so it does not appear in the Spanish list.
- i18n
Guides
Write posts, case studies, events and docs in Markdown or MDX, and page copy in YAML, in every language.
Add a collections section to src/config.yaml. Each collection names a preset, which fixes its fields and the blocks that show it. Your editor autocompletes the keys.
collections:
timezone: 'Europe/Madrid'
posts: { preset: post, route: /blog, pageSize: 9 }
cases: { preset: caseStudy, route: /work }
events: { preset: event, route: /events }| Key | Default | Meaning |
|---|---|---|
preset |
required | post, caseStudy, event or doc |
route |
/<name> |
URL base the cards link to, without the language prefix |
path |
src/content/<name> |
Content folder |
sort |
date-desc; events start-asc; docs order-asc |
Also date-asc, title-asc, order-asc |
pageSize |
none | Entries per list page; unset means one page |
timezone |
UTC |
Reserved key: the zone event times show in |
Every preset has title, description (the card excerpt and meta description), cover, ogImage, tags, featured, draft and slug. On top of those:
post: date, updated, author.caseStudy: date, client, results (label, value), location.event: start, end, timezone, location, registrationUrl.doc: section, order.A location is a name (Online) or an object with name, address, lat, lon and zoom. With coordinates, the entry page shows a map. The site’s src/content.config.ts is one line, and getCollection('posts') is typed from the preset:
import { defineBlocksCollections } from '@alfadormx/blocks/content';
export const collections = defineBlocksCollections();Entries are .md or .mdx files. Put each language in its own folder. Files with the same name are translations of one entry. An entry missing from a language is left out of that language’s list and gets no URL there. A collection with no language folders is in the default language only, and its subfolders become part of each key (guides/install). Mixing language folders with other files or folders stops the build.
src/content/posts/
en/hello-world.md
es/hello-world.md ← same file name: the Spanish translation
en/english-only.md ← no es file: hidden in SpanishAn .mdx entry can import blocks and render them inline, and import any file as text with ?raw.
slug sets the URL segment in that language; it defaults to the file name. The slug page is reserved for pagination. Drafts show in development and are left out of pnpm build. Reading time is computed from the text.
---
title: Hola, mundo
description: Por qué la librería incluye colecciones Markdown.
date: 2026-10-01
slug: hola-mundo # optional: the URL segment in this language
tags: [anuncio]
draft: true # optional: left out of production builds
cover:
src: ~/assets/images/cover.webp
alt: Describe the image
---The pages stay yours: use your own layout, header and footer. The helpers handle languages, drafts, sorting, pagination (/blog, /blog/page/2) and the language toggle, which links each translation to its own slug and a missing one to that language’s list. They also emit hreflang links for the languages that have the page.
---
import Layout from '@alfadormx/blocks/Layout.astro';
import Header from '@alfadormx/blocks/composite/Header.astro';
import Footer from '@alfadormx/blocks/composite/Footer.astro';
import Container from '@alfadormx/blocks/layout/Container.astro';
import CollectionList from '@alfadormx/blocks/composite/CollectionList.astro';
import { collectionPages, renderList } from '@alfadormx/blocks/collections';
export const getStaticPaths = () => collectionPages('posts');
const { langCode, entries, page } = await renderList(Astro);
---
<Layout langCode={langCode} metadata={{ title: { default: 'Blog' } }}>
<Header themeToggle={{}} />
<Container>
<CollectionList entries={entries} page={page} langCode={langCode} />
</Container>
<Footer languageToggle={{}} />
</Layout>---
import Layout from '@alfadormx/blocks/Layout.astro';
import Header from '@alfadormx/blocks/composite/Header.astro';
import Footer from '@alfadormx/blocks/composite/Footer.astro';
import Container from '@alfadormx/blocks/layout/Container.astro';
import PostLayout from '@alfadormx/blocks/composite/PostLayout.astro';
import { collectionEntries, renderEntry } from '@alfadormx/blocks/collections';
export const getStaticPaths = () => collectionEntries('posts');
const { Content, langCode, layout, metadata } = await renderEntry(Astro, 'posts');
---
<Layout langCode={langCode} metadata={metadata}>
<Header themeToggle={{}} />
<Container>
<PostLayout {...layout}><Content /></PostLayout>
</Container>
<Footer languageToggle={{}} />
</Layout>Use CaseStudyLayout or EventLayout for the other presets. To link to a list from anywhere, collectionUrl('posts', langCode) returns its URL in that language. See the blog, case study and event demos. After a build, a warning names any collection whose route has no entry page.
A doc collection has no list page and no card. This site’s documentation collection is single-language, and its keys are <section>/<Block> (primitives/Button), so its entry page is src/pages/documentation/[...slug].astro. That route has no lang param, so its getStaticPaths keeps only slug from collectionEntries('documentation'). collectionIndex('documentation', langCode) returns the entries in sort order, each with its URL, and feeds the docs sidebar and previous/next links. An entry’s section must match its folder, and a slug is rejected: a docs URL is its file path. Guides live in guides/ like any other section; the old /documentation/Composing and /documentation/Collections URLs redirect there.
featured: true doesn’t change the list order. Use getFeatured for a “Featured” section anywhere:

Nov 1, 2026 · 1 min read
This entry has no Spanish translation, so it does not appear in the Spanish list.

Oct 15, 2026 · 1 min read
Translations live in a folder per language and link by filename.

Oct 1, 2026 · 1 min read
Why this library ships Markdown collections, and what a post looks like.
---
import CollectionListBlock from '@alfadormx/blocks/composite/CollectionList.astro';
import { getFeatured } from '@alfadormx/blocks/collections';
const featured = await getFeatured('posts', 3, 'en');
---
<CollectionListBlock entries={featured} columns={2} />Write the page once under src/pages/[...lang]/, and its copy in YAML per language. The default-language file defines the keys, and copy is typed from it, so a typo fails astro check. Objects merge key by key; arrays replace as a whole, so a translated list is never half English.
src/copy/home/
en.yaml ← the default language defines the keys and their types
es.yaml ← missing keys fall back to en, with a build warning
intro.md ← referenced from a YAML value as ./intro.md---
import { localizedPaths, useCopy } from '@alfadormx/blocks/copy';
export const getStaticPaths = () => localizedPaths();
const { langCode, copy } = useCopy(Astro, 'home');
---
<Layout langCode={langCode} metadata={{ title: { default: copy.pageTitle } }}>
<Hero headline={{ title: copy.hero.title }} />
<Footer disclaimer={copy.footerDisclaimer} />
</Layout>A YAML value of the form ./name.md is replaced with that file, read relative to the YAML. Use it for long sections. It renders as Markdown only in a RichText field; in a plain field such as a title, the raw text shows.
Item content, Accordion item content, Footer disclaimer and footnote, and Container item content take Markdown. One line renders inline; paragraphs separated by a blank line, lists and headings render as blocks. HTML still passes through. Titles, labels and alt stay plain text.
Events are sorted upcoming first, then past, with a “Past” badge. That is decided when the site builds, so schedule a daily rebuild (a cron job in your host or CI) to move events into the past on time.
Replace the stub with your own Astro config and spread the library’s collections into it, to add collections of your own:
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
import { defineBlocksCollections } from '@alfadormx/blocks/content';
export const collections = {
...defineBlocksCollections(),
notes: defineCollection({
loader: glob({ base: 'src/content/notes', pattern: '**/*.{md,mdx}' }),
schema: z.object({ title: z.string() }),
}),
};