MCPcopy Create free account
hub / github.com/PerroEngine/Perro / sitemap_xml

Function sitemap_xml

perro_website/src/main.rs:284–335  ·  view source on GitHub ↗
(headers: axum::http::HeaderMap)

Source from the content-addressed store, hash-verified

282 y: i32,
283 size: i32,
284 line_height: i32,
285 class_name: &str,
286) -> String {
287 lines
288 .iter()
289 .enumerate()
290 .map(|(index, line)| {
291 format!(
292 r#"<text x="{x}" y="{}" class="{class_name}" font-family="Arial, Helvetica, sans-serif" font-size="{size}" font-weight="800" fill="{}">{}</text>"#,
293 y + (index as i32 * line_height),
294 if class_name == "title" { "#f8fbff" } else { "#c7d3df" },
295 xml_escape(line)
296 )
297 })
298 .collect::<Vec<_>>()
299 .join("\n ")
300}
301
302#[cfg(feature = "ssr")]
303async fn sitemap_xml(headers: axum::http::HeaderMap) -> impl axum::response::IntoResponse {
304 let base = public_base_url(&headers);
305 let mut urls = vec![
306 SitemapUrl::new("", "weekly", "1.0"),
307 SitemapUrl::new("features", "monthly", "0.8"),
308 SitemapUrl::new("mission", "monthly", "0.7"),
309 SitemapUrl::new("book", "weekly", "0.9"),
310 SitemapUrl::new("nodes", "weekly", "0.9"),
311 SitemapUrl::new("learn/getting-started", "monthly", "0.8"),
312 SitemapUrl::new("docs", "weekly", "0.9"),
313 SitemapUrl::new("examples", "weekly", "0.9"),
314 SitemapUrl::new("examples/2d", "weekly", "0.8"),
315 SitemapUrl::new("examples/3d", "weekly", "0.8"),
316 SitemapUrl::new("news", "monthly", "0.5"),
317 SitemapUrl::new("community", "monthly", "0.5"),
318 SitemapUrl::new("assets", "monthly", "0.7"),
319 SitemapUrl::new("sponsor", "monthly", "0.4"),
320 ];
321 urls.extend(
322 perro_website_lib::docs::docs()
323 .iter()
324 .filter(|doc| doc.route_path != "/book" && doc.route_path != "/docs")
325 .map(|doc| {
326 SitemapUrl::new(
327 doc.route_path.trim_start_matches('/'),
328 "monthly",
329 doc_priority(doc),
330 )
331 }),
332 );
333
334 let mut xml = String::from(
335 r#"<?xml version="1.0" encoding="UTF-8"?>
336<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
337"#,
338 );

Callers

nothing calls this directly

Calls 8

public_base_urlFunction · 0.85
docsFunction · 0.85
doc_priorityFunction · 0.85
xml_escapeFunction · 0.85
extendMethod · 0.80
cloneMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected