Skip to main content

frontmatter_paths

Function frontmatter_paths 

Source
pub fn frontmatter_paths(fm: &Mapping) -> Vec<RawLink>
Expand description

Frontmatter string values that name a file by path (cover: img/a.png), tagged with their top-level key. A value counts when its last segment has an extension; a URL, a wikilink or text with a line break does not. Whether the path exists is the resolver’s question.

§Examples

use markdown_link::frontmatter_paths;

let fm = yaml_splice::parse::parse_mapping(
    "cover: img/a.png\nsite: https://x.org/a.png\nname: plain\n",
)
.unwrap();
let paths = frontmatter_paths(&fm);
assert_eq!(paths.len(), 1);
assert_eq!(paths[0].target, "img/a.png");
assert_eq!(paths[0].field.as_deref(), Some("cover"));