Crates.io | sitemap-writer |
lib.rs | sitemap-writer |
version | 0.1.1 |
source | src |
created_at | 2022-06-09 13:22:22.824243 |
updated_at | 2023-10-31 23:11:12.854048 |
description | Simple Sitemap Writer |
homepage | |
repository | https://github.com/uiuifree/rust-sitemap-writer |
max_upload_size | |
id | 602607 |
size | 6,422 |
Simple Write Sitemap
[dependencies]
sitemap-writer="0.1"
use sitemap::{SitemapWriter,SitemapUrl,SitemapChangeFreq};
let write = SitemapWriter::make("test.xml", vec![
SitemapUrl{
loc: "https://example.com/".to_string(),
lastmod: Some("2021-01-01".to_string()),
changefreq: Some(SitemapChangeFreq::ALWAYS),
priority: Some(1.0),
},
SitemapUrl::new("https://example.com/contact/"),
SitemapUrl::new("https://example.com/contact/?test=1"),
SitemapUrl::new("https://example.com/contact/?test=<>"),
]);
assert!(write.is_ok())
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2021-01-01</lastmod>
<changefreq>always</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://example.com/contact/</loc>
</url>
<url>
<loc>https://example.com/contact/?test=1</loc>
</url>
<url>
<loc>https://example.com/contact/?test=<></loc>
</url>
</urlset>