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§
Sourcefn create<T: AsRef<Path>>(
blog: T,
toc_generation_func: Option<&dyn Fn(&Node) -> String>,
preview_chars: Option<usize>,
) -> Result<Self, BlogError>
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)
- 2023-01-01
- 2023
- blog
-
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.
Sourcefn get_date_listed(&self) -> NaiveDate
fn get_date_listed(&self) -> NaiveDate
Get the original publication date
Sourcefn get_description(&self) -> Option<String>
fn get_description(&self) -> Option<String>
Get the SEO description
Sourcefn get_full_slug(&self) -> String
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
Sourcefn get_part_slug(&self) -> String
fn get_part_slug(&self) -> String
Get the partial slug of the blog. This would be the slug
field from the
JSON
Get a list of tags for the blog
Sourcefn get_table_of_contents(&self) -> Option<String>
fn get_table_of_contents(&self) -> Option<String>
Get the table of contents. Only present if a table of contents funciton was provided
Sourcefn get_keywords(&self) -> Option<Vec<String>>
fn get_keywords(&self) -> Option<Vec<String>>
Get keywords
Sourcefn get_canonicle_link(&self) -> Option<String>
fn get_canonicle_link(&self) -> Option<String>
Get the canonicle link
Get the author
Get the author webpage
Sourcefn get_preview(&self) -> String
fn get_preview(&self) -> String
Get the blog preview. This is the first few hundred characters of the blog, useful for an index page
Sourcefn get_last_modified(&self) -> Option<NaiveDate>
fn get_last_modified(&self) -> Option<NaiveDate>
Get the last modified date, mostly use for sitemaps. This is not the original publication date
Sourcefn get_priority(&self) -> Option<f64>
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.