Skip to content

Commit 3bd6e0f

Browse files
caugnerfiji-flo
andauthored
enhance(sidebars): add guides/tutorials to APIRef (#224)
* feat(sidebars): add guides/tutorials to APIRef * avoid String allocation --------- Co-authored-by: Florian Dieminger <[email protected]>
1 parent 444c6b4 commit 3bd6e0f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

crates/rari-doc/src/sidebars/apiref.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub fn sidebar(slug: &str, group: Option<&str>, locale: Locale) -> Result<MetaSi
2828
Cow::Borrowed(l10n_json_data("Common", "Related_pages_wo_group", locale)?)
2929
};
3030
let events_label = l10n_json_data("Common", "Events", locale)?;
31+
let guides_label = l10n_json_data("Common", "Guides", locale)?;
32+
let tutorial_label = l10n_json_data("Common", "Tutorial", locale)?;
3133

3234
let main_if = slug
3335
.strip_prefix("Web/API/")
@@ -119,6 +121,23 @@ pub fn sidebar(slug: &str, group: Option<&str>, locale: Locale) -> Result<MetaSi
119121
build_interface_list(&mut entries, &inherited, inheritance_label);
120122
build_interface_list(&mut entries, &related, &related_label);
121123

124+
if let Some(groups) = web_api_groups {
125+
let guides: Vec<Page> = groups
126+
.guides
127+
.iter()
128+
.filter_map(|slug| slug.strip_prefix("/docs/"))
129+
.filter_map(|slug| Doc::page_from_slug(slug, locale, true).ok())
130+
.collect();
131+
let tutorial: Vec<Page> = groups
132+
.tutorial
133+
.iter()
134+
.filter_map(|slug| slug.strip_prefix("/docs/"))
135+
.filter_map(|slug| Doc::page_from_slug(slug, locale, true).ok())
136+
.collect();
137+
build_sublist(&mut entries, &guides, guides_label);
138+
build_sublist(&mut entries, &tutorial, tutorial_label);
139+
}
140+
122141
Ok(MetaSidebar {
123142
entries,
124143
..Default::default()

0 commit comments

Comments
 (0)