diff --git a/Cargo.toml b/Cargo.toml index 4a9142e..1b39cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blog-tools" -version = "0.1.2" +version = "0.2.0" edition = "2021" authors = ["Indigo Curnick "] description = "A collection of tools that helps make blogs in Rust" @@ -17,6 +17,7 @@ walkdir = "2.3.2" chrono = { version = "0.4.23", features = ["serde"] } markdown = "1.0.0-alpha.11" tl = "0.7.8" +xml = "0.8.20" [dev-dependencies] diff --git a/README.md b/README.md index 9537bda..a35960f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ next to a `blog.json`. The JSON must conform to the following schema -```rust,ignore +```json,ignore { "title": String, "date": ISO 8601 Date i.e. YYYY-MM-DD, @@ -27,7 +27,9 @@ The JSON must conform to the following schema "keywords": Optional<[String]>, "canonical_link": Optional, "author_name": Optional, -"author_webpage": Optional +"author_webpage": Optional, +"last_modified": Optional, (ISO 8601) +"priority": Optional } ``` @@ -36,7 +38,6 @@ The JSON must conform to the following schema In `blog-tools` all slugs are /{date}/{sub-slug}. Make sure the "slug" filed in the JSON is *just* the final sub-slug -- `blog-tools` will automatically handle the date for you ## How This Crate is Organised @@ -56,7 +57,7 @@ the best way to do this is using a lazy static like so ```rust,ignore lazy_static! { pub static ref STATIC_BLOG_ENTRIES: HighBlog = - get_high_blog(PathBuf::from(BLOG_ROOT), None, None); + get_high_blog(PathBuf::from(BLOG_ROOT), None, None, URL, &SitemapOptions::default()); } ``` @@ -66,7 +67,7 @@ blog posts themselves. These will need to be rendered when requested ```rust,ignore lazy_static! { pub static ref STATIC_BLOG_ENTRIES: MediumBlog = - get_medium_blog(PathBuf::from(BLOG_ROOT), None, None); + get_medium_blog(PathBuf::from(BLOG_ROOT), None, None, URL, &SitemapOptions::default()); } let this_blog = match all_blogs.hash.get(&complete_slug) { @@ -88,6 +89,7 @@ everything at runtime. let preview = preview_blogs(PathBuf::from_str(BLOG_ROOT).unwrap(), 2, None); let tags = get_blog_tag_list(PathBuf::from_str(BLOG_ROOT).unwrap()); let blog_post = render_blog_post(PathBuf::from_str(BLOG_ROOT).unwrap(), date, slug, None).unwrap(); +let sitemap = create_sitemap(BLOG_ROOT, URL, &SitemapOptions::default()); ``` This method can have serious runtime performance implecations, but might be diff --git a/examples/assets/favicon.ico b/examples/assets/favicon.ico new file mode 100644 index 0000000..7904e09 Binary files /dev/null and b/examples/assets/favicon.ico differ diff --git a/examples/high/main.rs b/examples/high/main.rs index 43ad906..87a1cb7 100644 --- a/examples/high/main.rs +++ b/examples/high/main.rs @@ -1,10 +1,13 @@ +use std::fs; use std::path::PathBuf; use blog_tools::high::{get_high_blog, HighBlog, HighBlogEntry}; +use blog_tools::sitemap::SitemapOptions; +use blog_tools::Blog; use lazy_static::lazy_static; use rocket::{ fs::{relative, FileServer}, - response::Redirect, + response::{content::RawXml, Redirect}, Request, Route, }; use rocket_dyn_templates::Template; @@ -41,6 +44,13 @@ fn blog_index() -> Option