[−][src]Struct blarf::article::Article
Data container for a single article
Fields
markdown: String
Raw markdown of article
slug: String
title: String
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>");
pub fn render_footer(
index: usize,
articles: &[Article],
email: Option<&str>
) -> String
[src]
index: usize,
articles: &[Article],
email: Option<&str>
) -> String
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
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,