Component Reference
This page documents the options accepted and values returned from the <Score> component and getScore() function.
<Score>
Section titled “<Score>”import { Score } from "astro-lilypond";
interface ScoreProps { content: LilypondScore; format?: "svg" | "png"; crop?: boolean; pageLimit?: number; class?: string; style?: string; alt?: string;}---import { Score } from "astro-lilypond";import bachInvention from "./bach-invention.ly";---
<Score content={bachInvention} />content
Section titled “content”Type: LilypondScore
The score’s source text and derived metadata. You get one from:
- Importing a
.ly/.ily/.lilypondfile directly. - A
lilypondLoader()content-collection entry;entry.datais aLilypondScore.
format
Section titled “format”Type: "svg" | "png"
Default: the integration’s defaults.format ("svg" unless configured otherwise)
Output format for the rendered image.
Type: boolean
Default: false
Crops the score to a single tightly-fit image instead of full pages — see cropping.
pageLimit
Section titled “pageLimit”Type: number
Render only the first n pages. If omitted, all pages render. See limiting rendered pages.
Type: string
Class name(s) applied to the rendered <img> (or <ol>, for multi-page scores). See the styling guide.
Type: string
Inline styles applied directly to the rendered element.
Type: string
Overrides the automatically-derived alt text. Takes precedence over any title/composer found in the .ly file’s \header block. See also: alt text.
getScore()
Section titled “getScore()”import { getScore } from "astro-lilypond";
function getScore( score: LilypondScore, options?: GetScoreOptions,): Promise<GetScoreResult>;Type: LilypondScore
Same as <Score />’s content above.
options
Section titled “options”Type: GetScoreOptions
options.format
Section titled “options.format”Type: "svg" | "png"
Default: the integration’s defaults.format ("svg" unless configured otherwise)
Output format for Score.
options.crop
Section titled “options.crop”Type: boolean
Default: false
Crops Score to a single tightly-fit image instead of returning full pages. See the component guide.
options.pdf
Section titled “options.pdf”Type: boolean
Default: false
When true, also renders a downloadable PDF of the same score, returned as pdf.
---import { getScore } from "astro-lilypond";import bachInvention from "./bach-invention.ly";
const { Score, pdf, meta } = await getScore( bachInvention, { crop: true, pdf: true });---
<h3>{meta.title}</h3><Score /><a href={pdf.src} download>Download PDF</a>Return value
Section titled “Return value”Type: GetScoreResult
interface GetScoreResult { Score: AstroComponentFactory; pages: LilypondPage[]; meta: LilypondMetadata; raw: string; pdf?: LilypondPdfResult;}Type: AstroComponentFactory
Accepts all the same props as <Score>, except for format and crop; pass those to the options argument of getScore().
Type: LilypondPage[]
interface LilypondPage { src: string; width?: number; height?: number;}Every rendered page’s src/width/height, exposed so you can compose your own markup instead of using the markup from Score.
Type: LilypondMetadata
Fields parsed from the score’s \header block(s) — see the LilypondMetadata type below.
Type: string
Your LilyPond source code as a string, exactly as passed to getScore() (including any \version prepended via defaults.version). Use it wherever you need to show the text itself, rather than the rendered image.
Type: LilypondPdfResult | undefined
interface LilypondPdfResult { src: string;}Present only when options.pdf is true.
LilypondMetadata type
Section titled “LilypondMetadata type”Fields parsed from the score’s \header block(s) — the shape of meta on getScore() results.
interface LilypondMetadata { 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;
// Any other unknown or uncommon fields [field: string]: string | undefined;}