(frontmatter_json: &str, keys: &[&str])
| 265 | } |
| 266 | |
| 267 | fn frontmatter_string(frontmatter_json: &str, keys: &[&str]) -> Option<String> { |
| 268 | let value = serde_json::from_str::<serde_json::Value>(frontmatter_json).ok()?; |
| 269 | keys.iter() |
| 270 | .find_map(|key| value.get(key).and_then(|item| item.as_str())) |
| 271 | .filter(|item| !item.is_empty()) |
| 272 | .map(String::from) |
| 273 | } |
| 274 | |
| 275 | fn frontmatter_name(frontmatter_json: &str) -> Option<String> { |
| 276 | frontmatter_string(frontmatter_json, &["name"]) |
no test coverage detected