Skip to content

Configuration

Pass options to the integration when registering it in astro.config.mjs:

astro.config.mjs
import { defineConfig } from 'astro/config';
import lilypond from 'astro-lilypond';
export default defineConfig({
integrations: [
lilypond({
// config
}),
],
});

Type: string
Default: undefined

All LilyPond content must specify \version at the start so that the compiler knows how to output the score.

```lilypond
\version "2.24.0"
\relative c' { c4 d e f }
```

Specify a version in the LilyPond config to apply it to all LilyPond blocks by default:

astro.config.mjs
export default defineConfig({
integrations: [
lilypond({
version: "2.24.0"
}),
],
});

With version set in the config, blocks can omit it.

Blocks with an explicit \version declaration will always use that version, regardless of the global config.

Type: "svg" | "png" | { type: "png"; resolution: number }
Default: "svg"

The output format passed to the LilyPond binary. Controls how the rendered output is embedded in the page.

astro.config.mjs
export default defineConfig({
integrations: [
lilypond({
format: "png"
}),
],
});
Value Embedded as
"svg" Inline <svg> element (default)
"png" <img> element with a base64 data URI, at the default resolution (144 DPI)
{ type: "png", resolution: number } <img> element with a base64 data URI, at the specified DPI

If you need higher quality PNGs, pass an object with type: "png" and resolution:

astro.config.mjs
export default defineConfig({
integrations: [
lilypond({
format: {
type: "png",
resolution: 300
}
}),
],
});

Type: boolean
Default: true

When true, the margins are removed and the page is cropped to fit the rendered staves.

Set to false to preserve full page dimensions:

astro.config.mjs
export default defineConfig({
integrations: [
lilypond({
crop: false
}),
],
});