This commit is contained in:
Edgar 2020-11-22 15:47:10 +01:00
parent 11dc59ff46
commit a859a3f363
No known key found for this signature in database
GPG key ID: 8731E6C0166EAA85
2 changed files with 37 additions and 1 deletions

View file

@ -8,6 +8,8 @@ To handle the `lastmod` tag it uses [chrono](https://docs.rs/chrono/) but it can
## Example
To run the examples use `cargo run --example gen_sitemap`
```rust
use chrono::prelude::*;
use sitewriter::*;
@ -49,3 +51,37 @@ fn main() {
println!("{}", result);
}
```
Prints the following:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://edgarluque.com/projects</loc>
</url>
<url>
<loc>https://edgarluque.com/</loc>
<lastmod>2020-11-22T14:36:30Z</lastmod>
<priority>1.0</priority>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://edgarluque.com/blog</loc>
<lastmod>2020-11-22T14:36:30Z</lastmod>
<priority>0.8</priority>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>https://edgarluque.com/blog/sitewriter</loc>
<lastmod>2020-11-22T15:10:15Z</lastmod>
<priority>0.5</priority>
<changefreq>never</changefreq>
</url>
<url>
<loc>https://edgarluque.com/blog/some-future-post</loc>
<lastmod>2020-12-05T11:30:00Z</lastmod>
<priority>0.5</priority>
<changefreq>never</changefreq>
</url>
</urlset>
```

View file

@ -35,7 +35,7 @@ impl Display for ChangeFreq {
}
}
/// Parent tag for each URL entry.
/// A sitemap url entry.
#[derive(Debug)]
pub struct Url<'a> {
/// URL of the page.