Skip to main content

read_sidecar

Function read_sidecar 

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

Reads a .meta.json sidecar for a given HTML file path.

Looks for <stem>.meta.json alongside the HTML file. Returns None if the sidecar does not exist.

§Examples

use ssg::frontmatter::read_sidecar;
use tempfile::tempdir;

let dir = tempdir().unwrap();
let html = dir.path().join("page.html");
// No sidecar present ⇒ Ok(None).
assert!(read_sidecar(&html).unwrap().is_none());