| 347 | } |
| 348 | |
| 349 | fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> { |
| 350 | match fm.get(key) { |
| 351 | Some(Value::Array(items)) => items |
| 352 | .iter() |
| 353 | .filter_map(|v| v.as_str().map(str::to_string)) |
| 354 | .collect(), |
| 355 | Some(Value::String(s)) if !s.is_empty() => s |
| 356 | .split(',') |
| 357 | .map(|p| p.trim().to_string()) |
| 358 | .filter(|p| !p.is_empty()) |
| 359 | .collect(), |
| 360 | _ => Vec::new(), |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | /// Minimal frontmatter splitter for a full markdown document: |
| 365 | /// `---\n<key: value lines>\n---\n<body>`. Enough for templates and the CLI; |