scraps 3.7.0

Scraps is a portable CLI knowledge hub for managing interconnected Markdown documentation with Wiki-link notation.
use itertools::Itertools;

use scraps_libs::model::{page_path::PagePath, scrap::Scrap};

#[derive(serde::Serialize, Clone, PartialEq, Debug)]
struct SerializeLinkScrap {
    ctx: Option<String>,
    /// What a wiki-link to the scrap holds: its path without `.md`.
    key: String,
    title: String,
    /// Page URL relative to `base_url`, already percent-encoded.
    url_path: String,
}

impl SerializeLinkScrap {
    fn new(scrap: &Scrap) -> SerializeLinkScrap {
        let url_path = PagePath::of_scrap(&scrap.self_key()).to_url_path();
        SerializeLinkScrap {
            ctx: scrap.ctx().as_ref().map(|c| c.to_string()),
            key: scrap.self_key().to_string(),
            title: scrap.title().to_string(),
            url_path,
        }
    }
}

#[derive(serde::Serialize, PartialEq, Debug)]
pub struct LinkScrapsTera(Vec<SerializeLinkScrap>);

impl LinkScrapsTera {
    pub fn new(scraps: &[&Scrap]) -> LinkScrapsTera {
        let serialize_scraps = scraps
            .iter()
            .map(|scrap| SerializeLinkScrap::new(scrap))
            .collect_vec();

        LinkScrapsTera(serialize_scraps)
    }
}