sitemap-writer

Crates.iositemap-writer
lib.rssitemap-writer
version0.1.1
sourcesrc
created_at2022-06-09 13:22:22.824243
updated_at2023-10-31 23:11:12.854048
descriptionSimple Sitemap Writer
homepage
repositoryhttps://github.com/uiuifree/rust-sitemap-writer
max_upload_size
id602607
size6,422
Misaki (uiuifree)

documentation

README

features

Simple Write Sitemap

Using

[dependencies]
sitemap-writer="0.1"

Examples

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())

Output XML

<?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=&lt;&gt;</loc>
  </url>
</urlset>
Commit count: 5

cargo fmt