Trait Blog

Source
pub trait Blog: Clone {
Show 16 methods // Required methods fn create<T: AsRef<Path>>( blog: T, toc_generation_func: Option<&dyn Fn(&Node) -> String>, preview_chars: Option<usize>, ) -> Result<Self, BlogError>; fn get_title(&self) -> String; fn get_date_listed(&self) -> NaiveDate; fn get_description(&self) -> Option<String>; fn get_html(&self) -> String; fn get_full_slug(&self) -> String; fn get_part_slug(&self) -> String; fn get_tags(&self) -> Vec<String>; fn get_table_of_contents(&self) -> Option<String>; fn get_keywords(&self) -> Option<Vec<String>>; fn get_canonicle_link(&self) -> Option<String>; fn get_author_name(&self) -> Option<String>; fn get_author_webpage(&self) -> Option<String>; fn get_preview(&self) -> String; fn get_last_modified(&self) -> Option<NaiveDate>; fn get_priority(&self) -> Option<f64>;
}
Expand description

Primary trait that describes a single blog post. Any struct which derives this is intended to be converted into a JSON with serde and used in a template. You can of course use any of these other methods for any purpose in the blog

Required Methods§

Source

fn create<T: AsRef<Path>>( blog: T, toc_generation_func: Option<&dyn Fn(&Node) -> String>, preview_chars: Option<usize>, ) -> Result<Self, BlogError>

Create a blog post

Parameters

  • blog: Path to the root of the blog For this to work, you should have a folder, for instance, blog which serves as the root. Within this folder, you must have the following structure

    • blog
      • 2023
        • 2023-01-01
          • my_first_blog.json
          • my_first_blog.md
        • (other folders)
  • toc_generation_func - A function which parses a blog and generates a table of contents. Optional.

  • preview_chars - number of chars to be taken in the preview of the blog. Default is 320.

Source

fn get_title(&self) -> String

Get the blog title

Source

fn get_date_listed(&self) -> NaiveDate

Get the original publication date

Source

fn get_description(&self) -> Option<String>

Get the SEO description

Source

fn get_html(&self) -> String

Get the HTML of the blog

Source

fn get_full_slug(&self) -> String

Get the full slug - this would be e.g. 2024-03-19/my-blog. In the JSON, you should NOT include the date in the slug

Source

fn get_part_slug(&self) -> String

Get the partial slug of the blog. This would be the slug field from the JSON

Source

fn get_tags(&self) -> Vec<String>

Get a list of tags for the blog

Source

fn get_table_of_contents(&self) -> Option<String>

Get the table of contents. Only present if a table of contents funciton was provided

Source

fn get_keywords(&self) -> Option<Vec<String>>

Get keywords

Get the canonicle link

Source

fn get_author_name(&self) -> Option<String>

Get the author

Source

fn get_author_webpage(&self) -> Option<String>

Get the author webpage

Source

fn get_preview(&self) -> String

Get the blog preview. This is the first few hundred characters of the blog, useful for an index page

Source

fn get_last_modified(&self) -> Option<NaiveDate>

Get the last modified date, mostly use for sitemaps. This is not the original publication date

Source

fn get_priority(&self) -> Option<f64>

Get the priority for the sitemap

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§