query
Use a convenient query syntax to extract a child element from this frontmatter element.
Imagine you have the following frontmatter declaration:
title: Title
data:
assets:
images:
- cat.png
- dog.png
font: RobotoContent copied to clipboard
Once parsed into a FrontMatterElement, you can query it like so:
val fm: FrontMatterElement = ...
fm.query("title") // returns FrontMatterElement.Scalar
fm.query("data.assets.images") // returns FrontMatterElement.ValueList
fm.query("data.assets.images.1") // returns FrontMatterElement.Scalar
fm.query("data.assets.font") // returns FrontMatterElement.Scalar
fm.query("data.assets") // returns FrontMatterElement.ValueMap
fm.query("key-not-found") // returns nullContent copied to clipboard
You may prefer using the get operator in most cases, however, as that provides convenient access directly to nested string values, which is enough for a vast majority of the cases.