use super::dom::{attr_value, strip_text, tags_where};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DetailEntry {
pub column: String,
pub text: String,
}
pub fn detail_entries(html: &str) -> Vec<DetailEntry> {
tags_where(html, |_, attrs| attr_value(attrs, "data-entry").is_some())
.into_iter()
.map(|(_, attrs, inner)| DetailEntry {
column: attr_value(&attrs, "data-entry").unwrap_or_default(),
text: strip_text(&inner),
})
.collect()
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RecordNavLink {
pub href: String,
pub current: bool,
}
pub fn record_navigation(html: &str) -> Vec<RecordNavLink> {
tags_where(html, |_, attrs| {
attr_value(attrs, "data-record-nav").is_some()
})
.into_iter()
.map(|(_, attrs, _)| RecordNavLink {
href: attr_value(&attrs, "data-record-nav").unwrap_or_default(),
current: attr_value(&attrs, "aria-current").as_deref() == Some("page"),
})
.collect()
}