Skip to content

Commit

Permalink
Merge pull request #12 from rust-dd/feat/add-extra-features
Browse files Browse the repository at this point in the history
feat: update sitemap.xml
  • Loading branch information
dancixx authored Dec 21, 2024
2 parents e87c54c + 284d8b5 commit 3b4e5b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/pages/hireus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::time::Duration;
use leptos::prelude::*;
use crate::ssr::api::{hire_us, HireUsRequest};

Expand Down
19 changes: 19 additions & 0 deletions src/ssr/server_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,31 @@ pub async fn sitemap_handler(State(state): State<AppState>) -> Response<String>
let mut sitemap = String::new();
sitemap.push_str("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sitemap.push_str("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");

let static_urls = vec![
("https://rust-dd.com/", "daily", "0.9"),
("https://rust-dd.com/hireus", "weekly", "1.0"),
("https://rust-dd.com/references", "weekly", "0.6"),
("https://rust-dd.com/rss.xml", "daily", "0.5"),
("https://rust-dd.com/sitemap.xml", "monthly", "0.5"),
];

for (url, freq, priority) in static_urls {
sitemap.push_str("<url>\n");
sitemap.push_str(&format!("<loc>{}</loc>\n", url));
sitemap.push_str(&format!("<changefreq>{}</changefreq>\n", freq));
sitemap.push_str(&format!("<priority>{}</priority>\n", priority));
sitemap.push_str("</url>\n");
}

for post in posts {
sitemap.push_str("<url>\n");
sitemap.push_str(&format!(
"<loc>https://rust-dd.com/post/{}</loc>\n",
post.slug.unwrap()
));
sitemap.push_str("<changefreq>monthly</changefreq>\n");
sitemap.push_str("<priority>1.0</priority>\n");
sitemap.push_str(&format!("<lastmod>{}</lastmod>\n", post.created_at));
sitemap.push_str("</url>\n");
}
Expand Down

0 comments on commit 3b4e5b2

Please sign in to comment.