sitewriter/examples/gen_sitemap.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

2020-11-22 14:43:41 +00:00
use chrono::prelude::*;
use sitewriter::*;
fn main() {
let mut sitemap = Sitemap::new();
2020-11-23 09:22:41 +00:00
sitemap.urls.push(Url::new("https://edgarluque.com/projects".to_owned()));
2020-11-22 14:43:41 +00:00
sitemap.urls.push(Url {
2020-11-23 09:22:41 +00:00
loc: "https://edgarluque.com/".to_owned(),
2020-11-22 14:43:41 +00:00
changefreq: Some(ChangeFreq::Daily),
priority: Some(1.0),
lastmod: Some(Utc::now()),
});
sitemap.urls.push(Url {
2020-11-23 09:22:41 +00:00
loc: "https://edgarluque.com/blog".to_owned(),
2020-11-22 14:43:41 +00:00
changefreq: Some(ChangeFreq::Weekly),
priority: Some(0.8),
lastmod: Some(Utc::now()),
});
sitemap.urls.push(Url {
2020-11-23 09:22:41 +00:00
loc: "https://edgarluque.com/blog/sitewriter".to_owned(),
2020-11-22 14:43:41 +00:00
changefreq: Some(ChangeFreq::Never),
priority: Some(0.5),
lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)),
});
sitemap.urls.push(Url {
2020-11-23 09:22:41 +00:00
loc: "https://edgarluque.com/blog/some-future-post".to_owned(),
2020-11-22 14:43:41 +00:00
changefreq: Some(ChangeFreq::Never),
priority: Some(0.5),
lastmod: Some(Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc())),
});
let result = sitemap.into_str();
println!("{}", result);
}