The block registry is a single TypeScript file that auto-discovers every block component and exposes them as a unified lookup map. It is the mechanism that makes the page builder work without any manual registration.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gsinghjay/astro-shadcn-sanity/llms.txt
Use this file to discover all available pages before exploring further.
Full source
How custom blocks are mapped
The custom block loop reads each*.astro file from ./blocks/custom/, strips the extension, and lowercases the first character:
name field in the Sanity schema for that block. Because defineBlock creates a Sanity object type with the name you provide, keeping the PascalCase filename and the camelCase schema name in sync is the only naming convention you need to follow.
Current custom block registrations
| Filename | Registered _type |
|---|---|
AnnouncementBar.astro | announcementBar |
ArticleList.astro | articleList |
ComparisonTable.astro | comparisonTable |
ContactForm.astro | contactForm |
CtaBanner.astro | ctaBanner |
Divider.astro | divider |
EventList.astro | eventList |
FaqSection.astro | faqSection |
FeatureGrid.astro | featureGrid |
HeroBanner.astro | heroBanner |
ImageGallery.astro | imageGallery |
LogoCloud.astro | logoCloud |
ProjectCards.astro | projectCards |
Pullquote.astro | pullquote |
RichText.astro | richText |
SponsorCards.astro | sponsorCards |
SponsorshipTiers.astro | sponsorshipTiers |
SponsorSteps.astro | sponsorSteps |
StatsRow.astro | statsRow |
TeamGrid.astro | teamGrid |
Testimonials.astro | testimonials |
TextWithImage.astro | textWithImage |
Timeline.astro | timeline |
VideoEmbed.astro | videoEmbed |
How template blocks are mapped
The template block loop reads each*.astro file from ./blocks/ (the root of the blocks directory, not custom/) and uses the filename verbatim as the key:
_type string that must appear in Sanity.
The allBlocks export
allBlocks is a plain Record<string, AstroComponentFactory>. An AstroComponentFactory is the internal Astro type for a renderable component — exactly what you get from a .astro file’s default export.
Only BlockRenderer imports allBlocks. Nothing else in the codebase references it directly.
How BlockRenderer uses allBlocks
block._typeis the Sanity type name stored on each block in theblocks[]array.allBlocks[block._type]either resolves to a component or isundefined.- If
undefined, the block is skipped — the page renders without it and no error is thrown. - If resolved, the component receives every field on the block object as a top-level prop via
{...block}.
Why there is no switch statement
Earlier versions of similar projects use aswitch (block._type) in the renderer with an explicit case for every block type. This creates a maintenance burden: every new block requires editing the renderer.
The registry pattern eliminates that. Adding a block means:
- Drop an
.astrofile in the right directory. - The
import.meta.globcall picks it up at build time. allBlocksgains the new key automatically.