sitewriter/README.md

83 lines
3.1 KiB
Markdown
Raw Permalink Normal View History

2021-10-19 15:11:10 +00:00
# sitewriter
2020-11-22 15:42:16 +00:00
2021-10-19 15:11:10 +00:00
### A library to generate sitemaps.
2020-11-22 14:43:41 +00:00
2021-10-19 15:11:10 +00:00
[![Version](https://img.shields.io/crates/v/sitewriter)](https://crates.io/crates/sitewriter)
[![Downloads](https://img.shields.io/crates/d/sitewriter)](https://crates.io/crates/sitewriter)
[![License](https://img.shields.io/crates/l/sitewriter)](https://crates.io/crates/sitewriter)
2021-10-19 15:14:04 +00:00
![Rust](https://github.com/edg-l/sitewriter/workflows/Rust/badge.svg)
2021-10-19 15:11:10 +00:00
[![Docs](https://docs.rs/sitewriter/badge.svg)](https://docs.rs/sitewriter)
2021-10-24 18:06:29 +00:00
[![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/sitewriter.svg)](https://web.crev.dev/rust-reviews/crate/sitewriter/)
2020-11-22 14:43:41 +00:00
2021-10-19 15:11:10 +00:00
It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast.
2020-11-22 14:43:41 +00:00
2021-10-19 15:11:10 +00:00
### Example
2020-11-22 14:47:10 +00:00
2020-11-22 14:43:41 +00:00
```rust
2021-10-19 15:11:10 +00:00
use chrono::prelude::*;
2021-12-14 07:53:27 +00:00
use sitewriter::{ChangeFreq, UrlEntry, UrlEntryBuilder};
2020-11-22 14:43:41 +00:00
2021-12-14 07:55:33 +00:00
let urls = vec![
UrlEntryBuilder::default()
.loc("https://edgarluque.com/projects".parse().unwrap())
.build()
.unwrap(),
UrlEntry {
loc: "https://edgarluque.com/".parse().unwrap(),
changefreq: Some(ChangeFreq::Daily),
priority: Some(1.0),
lastmod: Some(Utc::now()),
},
UrlEntry {
loc: "https://edgarluque.com/blog".parse().unwrap(),
changefreq: Some(ChangeFreq::Weekly),
priority: Some(0.8),
lastmod: Some(Utc::now()),
},
UrlEntry {
loc: "https://edgarluque.com/blog/sitewriter".parse().unwrap(),
changefreq: Some(ChangeFreq::Never),
priority: Some(0.5),
lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)),
},
UrlEntry {
loc: "https://edgarluque.com/blog/some-future-post"
.parse()
.unwrap(),
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()),
),
},
// Entity escaping
UrlEntry {
loc: "https://edgarluque.com/blog/test&id='<test>'"
.parse()
.unwrap(),
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()),
),
},
];
2020-11-22 14:43:41 +00:00
2021-12-14 07:55:33 +00:00
let result = sitewriter::generate_str(&urls);
println!("{}", result);
2020-11-22 14:43:41 +00:00
```
2020-11-22 14:47:10 +00:00
2021-10-24 18:06:29 +00:00
### CREV - Rust code reviews - Raise awareness
Please, spread this info !\
Open source code needs a community effort to express trustworthiness.\
Start with reading the reviews of the crates you use on [web.crev.dev/rust-reviews/crates/](https://web.crev.dev/rust-reviews/crates/) \
Than install the CLI [cargo-crev](https://github.com/crev-dev/cargo-crev)\. Follow the [Getting Started guide](https://github.com/crev-dev/cargo-crev/blob/master/cargo-crev/src/doc/getting_started.md). \
On your Rust project, verify the trustworthiness of all dependencies, including transient dependencies with `cargo crev verify`\
Write a new review ! \
Describe the crates you trust. Or warn about the crate versions you think are dangerous.\
Help other developers, inform them and share your opinion.\
Use [cargo_crev_reviews](https://crates.io/crates/cargo_crev_reviews) to write reviews easily.
2021-10-19 15:11:10 +00:00
License: MIT