Skip to main content

read_sidecar_for_html

Function read_sidecar_for_html 

Source
pub fn read_sidecar_for_html(
    html_path: &Path,
    site_dir: &Path,
    sidecar_dir: &Path,
) -> Result<Option<BTreeMap<String, Value>>>
Expand description

Reads a .meta.json sidecar matching an HTML path in the site dir, looking up by the corresponding content-relative path.

§Examples

use ssg::frontmatter::read_sidecar_for_html;
use tempfile::tempdir;

let dir = tempdir().unwrap();
let site = dir.path().join("site");
let sidecar = dir.path().join("sidecar");
let html = site.join("page.html");
// No sidecar dir or file ⇒ Ok(None).
assert!(read_sidecar_for_html(&html, &site, &sidecar).unwrap().is_none());