Skip to content

Collections Reference

lilypondLoader(), imported from astro-lilypond/loader, accepts the following options.

Type: string | URL
Required: yes

The directory pattern resolves from. Relative to the project root.

Type: string | string[]
Default: "**/*.{ly,ily,lilypond}"

Glob pattern(s) matching score files, relative to base.

Type: (options: { entry: string; base: URL; header: Record<string, string> }) => string
Default: the file’s path relative to base, with its extension stripped (e.g. preludes/prelude-1.ly becomes preludes/prelude-1).

Generates each entry’s collection id. header is the file’s parsed \header fields, so you can key ids off metadata instead of the file path if you’d like.

Type: "svg" | "png"
Default: "svg"

The image format each score is rendered to.

Type: object
Default: same as the integration’s defaults

Default settings applied to every score this loader renders.

Type: number
Default: 60000

Milliseconds to wait for a single lilypond invocation before aborting.

Each collection entry’s data has the following shape:

interface LilypondCollectionEntry {
// Rendered images
pages: {
src: string;
width?: number;
height?: number
}[];
// Autogenerated alt text
alt?: string;
// Header metadata
arranger?: string;
composer?: string;
copyright?: string;
dedication?: string;
instrument?: string;
meter?: string;
opus?: string;
piece?: string;
poet?: string;
subsubtitle?: string;
subtitle?: string;
tagline?: string;
title?: string;
// Everything else found in the file's \header block(s)
extra: Record<string, string>;
}

Data can be passed directly to the <LilyPond> component to render images:

MyScore.astro
---
import { getEntry } from "astro:content";
import LilyPond from "astro-lilypond/component";
const entry = await getEntry("scores", "my-score");
---
<h3>{entry.data.title}</h3>
<LilyPond content={entry.data} />