|
1 | 1 | use maud::{Markup, html}; |
2 | | -use maudit::{content::MarkdownHeading, route::PageContext}; |
| 2 | +use maudit::{ |
| 3 | + content::MarkdownHeading, |
| 4 | + route::{PageContext, RouteExt}, |
| 5 | +}; |
3 | 6 |
|
4 | | -use crate::content::{DocsContent, DocsSection}; |
| 7 | +use crate::{ |
| 8 | + content::{DocsContent, DocsSection}, |
| 9 | + routes::{DocsPage, DocsPageParams}, |
| 10 | +}; |
5 | 11 |
|
6 | 12 | pub fn left_sidebar(ctx: &mut PageContext) -> Markup { |
7 | 13 | let content = ctx.content.get_source::<DocsContent>("docs"); |
@@ -41,16 +47,16 @@ pub fn left_sidebar(ctx: &mut PageContext) -> Markup { |
41 | 47 | h2.text-xl.sm:text-lg.font-bold { (section) } |
42 | 48 | ul { |
43 | 49 | @for entry in entries { |
44 | | - @let url = &format!("/docs/{}", entry.id); |
45 | | - @let is_current_page = url == ctx.current_path; |
| 50 | + @let url = DocsPage.url(DocsPageParams { slug: entry.id.clone() }); |
| 51 | + @let is_current_page = url == *ctx.current_path; |
46 | 52 | li { |
47 | 53 | @let base_classes = "block py-2 sm:py-1 px-4 sm:px-3 text-lg sm:text-base font-medium sm:font-normal transition-colors border-b border-borders sm:border-0"; |
48 | 54 | @let conditional_classes = if is_current_page { |
49 | 55 | "text-brand-red sm:border-l-2 sm:border-l-brand-red" |
50 | 56 | } else { |
51 | 57 | "text-our-black hover:text-brand-red sm:border-l-2 sm:border-l-borders sm:hover:border-l-brand-red" |
52 | 58 | }; |
53 | | - a class=(format!("{} {}", base_classes, conditional_classes)) href=(format!("/docs/{}/", entry.id)) { |
| 59 | + a class=(format!("{} {}", base_classes, conditional_classes)) href=(url) { |
54 | 60 | (entry.data(ctx).title) |
55 | 61 | } |
56 | 62 | } |
|
0 commit comments