sitemap generates URL

This commit is contained in:
realaravinth
2021-07-25 20:15:44 +05:30
parent 189510c008
commit 0a8d36dc9f
7 changed files with 33 additions and 15 deletions

View File

@@ -66,6 +66,7 @@ pub mod routes {
pub sitekey: Sitekey,
pub notifications: &'static str,
pub settings: Settings,
pub stats: &'static str,
}
impl Panel {
@@ -75,10 +76,11 @@ pub mod routes {
sitekey: Sitekey::new(),
notifications: "/notifications",
settings: Settings::new(),
stats: "/stats",
}
}
pub const fn get_sitemap() -> [&'static str; 5] {
pub const fn get_sitemap() -> [&'static str; 6] {
const PANEL: Panel = Panel::new();
const S: [&str; 2] = Sitekey::get_sitemap();
@@ -88,6 +90,7 @@ pub mod routes {
S[0],
S[1],
Settings::get_sitemap()[0],
PANEL.stats,
]
}
}

View File

@@ -26,12 +26,19 @@ use crate::PAGES;
#[template(path = "sitemap.html")]
struct IndexPage {
urls: [&'static str; 7],
domain: &'static str,
}
impl Default for IndexPage {
fn default() -> Self {
let urls = Routes::get_sitemap();
Self { urls }
let domain = if crate::SETTINGS.server.domain.ends_with('/') {
&crate::SETTINGS.server.domain[0..crate::SETTINGS.server.domain.len() - 1]
} else {
&crate::SETTINGS.server.domain
};
Self { urls, domain }
}
}