fix breadcrumbs (they were broken)

This commit is contained in:
liquidex 2023-08-31 19:25:11 +02:00
parent fd4147b46c
commit 7f14916701

View file

@ -17,16 +17,16 @@ pub fn breadcrumbs_to_html(
if element != "index" { if element != "index" {
s.push_str("<li class=\"breadcrumb\">"); s.push_str("<li class=\"breadcrumb\">");
{ {
let element = path let short_element = path
.get(i - 1) .get(i - 1)
.map(|p| format!("{p}/")) .map(|p| format!("{p}/"))
.and_then(|prefix| element.strip_prefix(prefix.as_str()).map(Cow::Borrowed)) .and_then(|prefix| element.strip_prefix(prefix.as_str()).map(Cow::Borrowed))
.unwrap_or_else(|| Cow::Owned(format!("/{element}"))); .unwrap_or_else(|| Cow::Owned(format!("/{element}")));
write!( write!(
s, s,
"<a href=\"{site}/{element}.html\">{element}</a>", "<a href=\"{site}/{element}.html\">{short_element}</a>",
site = EscapeAttribute(&config.site), site = EscapeAttribute(&config.site),
element = EscapeAttribute(&element) element = EscapeAttribute(element)
) )
.unwrap(); .unwrap();
} }