28 lines
731 B
Markdown
28 lines
731 B
Markdown
|
# frontmatter
|
||
|
|
||
|
A library to parse TOML & YAML frontmatter either naively (as a serde_json::Map<String,serde_json::Value>) or to a native struct via serde.
|
||
|
|
||
|
This is very early stages software, just an experiment to learn how types work in Rust.
|
||
|
|
||
|
## Example:
|
||
|
|
||
|
```
|
||
|
use frontmatter::GenericFrontmatter;
|
||
|
|
||
|
struct PageFrontMatter {
|
||
|
title: Option<String>,
|
||
|
date: Option<String>
|
||
|
}
|
||
|
|
||
|
let body = "test: lol\ntest2: lol\nextra:\n extra_key: value";
|
||
|
let frontmatter = GenericFrontmatter::from_yaml(&body).expect("FAIL");
|
||
|
let special: PageFrontMatter = serde_json::from_value(frontmatter.into()).expect("FAIL2");
|
||
|
println!("{:?}", special);
|
||
|
```
|
||
|
|
||
|
## TODO
|
||
|
|
||
|
- JSON support
|
||
|
- file splitting: String -> (frontmatter, String)
|
||
|
- date parsing
|