Skip to content

Commit

Permalink
fix(templ): don't show duplicates in webextexamples
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Dec 20, 2024
1 parent d532969 commit d6fb9d8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/rari-doc/src/helpers/web_ext_examples.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::sync::LazyLock;

use rari_types::globals::data_dir;
Expand Down Expand Up @@ -40,10 +40,14 @@ pub fn web_ext_examples_json() -> &'static [WebExtExample] {
pub static WEB_EXT_EXAMPLES_DATA: LazyLock<WebExtExamplesData> = LazyLock::new(|| {
let mut by_module = HashMap::new();
for example in web_ext_examples_json() {
for js_api in &example.javascript_apis {
let js_api = &js_api[..js_api.find('.').unwrap_or(js_api.len())];
for js_api in &example
.javascript_apis
.iter()
.map(|js_api| &js_api[..js_api.find('.').unwrap_or(js_api.len())])
.collect::<HashSet<_>>()
{
by_module
.entry(js_api)
.entry(*js_api)
.and_modify(|e: &mut Vec<_>| e.push(example))
.or_insert(vec![example]);
}
Expand Down

0 comments on commit d6fb9d8

Please sign in to comment.