Skip to content

Commit

Permalink
fix(shot_title): derive short_title for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Oct 2, 2024
1 parent e5d11ec commit 28f461f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 0 additions & 6 deletions crates/rari-doc/src/helpers/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ use crate::error::DocError;
use crate::pages::page::{Page, PageLike};

pub fn transform_title(title: &str) -> &str {
if title.starts_with('<') {
if let Some(end) = title.find('>') {
return &title[..end + 1];
}
}

match title {
"Web technology for developers" => "References",
"Learn web development" => "Guides",
Expand Down
9 changes: 8 additions & 1 deletion crates/rari-doc/src/pages/types/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ impl PageLike for Doc {
}

fn short_title(&self) -> Option<&str> {
self.meta.short_title.as_deref()
self.meta.short_title.as_deref().or_else(|| {
if self.meta.title.starts_with('<') {
if let Some(end) = self.meta.title.find('>') {
return Some(&self.meta.title[..end + 1]);
}
}
None
})
}

fn locale(&self) -> Locale {
Expand Down

0 comments on commit 28f461f

Please sign in to comment.