Crate pichu

Crate pichu 

Source
Expand description

Pichu is the static site generator designed to evolve with your needs.

§Example

use serde::Deserialize;
use pichu::Markdown;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    pichu::glob("content/blog/*.md")?
        .parse_markdown::<Blogpost>()?
        .render_each(render_blog_post, |post| format!("dist/blog/{}/index.html", post.basename))?
        .render_all(render_blog, "dist/blog/index.html")?;
    Ok(())
}

#[derive(Debug, Deserialize)]
struct Blogpost {
    title: String,
}

fn render_blog_post(post: &Markdown<Blogpost>) -> String {
    format!("<h1>{}</h1>{}", post.frontmatter.title, post.html)
}

fn render_blog(posts: &Vec<Markdown<Blogpost>>) -> String {
    format!("{} posts", posts.len())
}

Structs§

Glob
A list of paths, probably created by [glob].
Markdown
A parsed markdown file.
Parsed
Parsed is a list of parsed items, ready to be sorted and rendered.

Enums§

Error
The error type returned in this crate.
MarkdownError
Error type for markdown parsing operations.
SassError
Error type for SASS/SCSS compilation operations.

Functions§

copy_dir
Copy the contents of a directory into another, recursively. Skips files starting with a ., except .well-known.
glob
Get a list of paths that match the given glob.
parse_markdown
Parse a markdown file at the given path.
render_sass
Render a SASS/SCSS file to the destination. Other SASS/SCSS files next to the provided one will be available for inclusion.
watch
Watch the given paths recursively and call the function on change.
write
Like fs::write, but creates directories as necessary.