[][src]Struct blarf::article::Article

pub struct Article {
    pub markdown: String,
    pub slug: String,
    pub title: String,
}

Data container for a single article

Fields

markdown: String

Raw markdown of article

slug: String

Short name of the article, appropriate for generating hyperlinks

Example:

1-my-first-post

title: String

Title of the article, appropriate for display

Example:

My First Post

Methods

impl Article[src]

pub fn new(markdown: String, slug: String) -> Article[src]

Constructor for Article

Note that this will attempt to write the title field of the Article using Article::get_title, defaulting to an empty string if none is found.

Example

let markdown = String::from("# My first post\nHello world!");
let slug = "1-my-first-post"
let article = Article::new(markdown, slug);

pub fn render(&self, css: &str, footer: &str) -> String[src]

Render the main template to html

Example

let html = article.render("styles.css", "<p>copyright 2019</p>");

Render a footer, with navigation controls based on position in list of articles

pub fn get_title(markdown: &str) -> Option<&str>[src]

Parse title from markdown

Returns text of first top-level heading (like # My first post), or None

Auto Trait Implementations

impl Send for Article

impl Sync for Article

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]