pub struct Parser<'a> { /* private fields */ }
Expand description
Parses Post
objects from source files.
Implementations§
source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
sourcepub fn new(
index_url: &'a Url,
posts_url: &'a Url,
posts_directory: &'a Path
) -> Parser<'a>
pub fn new( index_url: &'a Url, posts_url: &'a Url, posts_directory: &'a Path ) -> Parser<'a>
Constructs a new parser. See fields on Parser
for argument
descriptions.
sourcepub fn parse_posts(&self, source_directory: &Path) -> Result<Vec<Post>>
pub fn parse_posts(&self, source_directory: &Path) -> Result<Vec<Post>>
Searches a provided source_directory
for post files (extension =
.md
) and returns a list of Post
objects sorted by date (most
recent first). Each post file must be structured as follows:
- Initial frontmatter fence (
---
) - YAML frontmatter with fields
Title
,Date
, and optionallyTags
- Terminal frontmatter fence (
---
) - Post body
For example:
---
Title: Hello, world!
Date: 2021-04-16
Tags: [greet]
---
# Hello
World