aboutsummaryrefslogtreecommitdiff
path: root/src/modules/interests.rs
blob: 4383e65b5a06b2d36b11ab6ed0dbffd9011ea22b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::{collections::HashMap, sync::LazyLock};

type InterestMap = HashMap<String, HashMap<String, String>>;

static INTEREST_MAP: LazyLock<InterestMap> = LazyLock::new(|| {
  serde_json::from_str(include_str!("../../content/json/interests.json"))
    .unwrap()
});

pub fn module(router: &mut windmark::router::Router) {
  let mut contacts = INTEREST_MAP
    .iter()
    .map(|(category, contacts)| {
      format!("## {}\n\n{}", category, {
        let mut contacts = contacts
          .iter()
          .map(|(tag, href)| format!("=> {href} {tag}"))
          .collect::<Vec<_>>();

        contacts.sort();

        contacts.join("\n")
      })
    })
    .collect::<Vec<_>>();

  contacts.sort();

  crate::route::track_mount(
    router,
    "/interests",
    "A Few Interests of Fuwn",
    move |context| {
      crate::response::success(
        &format!(
          "# Interests\n\nA collection of things that I think are pretty neat \
           and I am considering using more in the future.\n\n{}",
          contacts.join("\n")
        ),
        &context,
      )
    },
  );
}