Highlight current module in the sidebar.

This commit is contained in:
KtorZ 2022-12-17 12:13:51 +01:00
parent a34d7d4dbb
commit 579030db36
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
3 changed files with 33 additions and 1 deletions

View File

@ -46,6 +46,15 @@ struct ModuleTemplate<'a> {
timestamp: String, timestamp: String,
} }
impl<'a> ModuleTemplate<'a> {
pub fn is_current_module(&self, module: &DocLink) -> bool {
match module.path.split(".html").next() {
None => false,
Some(name) => self.module_name == name,
}
}
}
#[derive(Template)] #[derive(Template)]
#[template(path = "page.html")] #[template(path = "page.html")]
struct PageTemplate<'a> { struct PageTemplate<'a> {
@ -61,6 +70,12 @@ struct PageTemplate<'a> {
timestamp: &'a str, timestamp: &'a str,
} }
impl<'a> PageTemplate<'a> {
pub fn is_current_module(&self, _module: &DocLink) -> bool {
false
}
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)] #[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
struct DocLink { struct DocLink {
name: String, name: String,

View File

@ -187,7 +187,13 @@
{% endif %} {% endif %}
<ul> <ul>
{% for module in modules %} {% for module in modules %}
<li><a href="{{ breadcrumbs }}/{{ module.path }}">{{ module.name }}</a></li> <li><a href="{{ breadcrumbs }}/{{ module.path }}">
{% if self.is_current_module(module) %}
<strong>{{ module.name }}</strong>
{% else %}
{{ module.name }}
{% endif %}
</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -324,6 +324,17 @@ p code {
margin-bottom: 4px; margin-bottom: 4px;
} }
.sidebar ul li a > strong {
font-weight: 900;
color: var(--color-link);
}
.sidebar ul li a > strong::before {
font-size: 0.75em;
content: 'ᐅ ';
padding-right: 0.1rem;
}
.sidebar .sidebar-toggle { .sidebar .sidebar-toggle {
color: var(--color-link); color: var(--color-link);
font-size: calc(0.8 * var(--sidebar-toggle-size)); font-size: calc(0.8 * var(--sidebar-toggle-size));