diff options
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs index aead105..0007cfb 100644 --- a/src/models.rs +++ b/src/models.rs @@ -167,6 +167,17 @@ pub struct Properties { pub properties: HashMap<String, PropertyValue>, } +impl Properties { + pub fn title(&self) -> Option<String> { + self.properties.values().find_map(|p| match p { + PropertyValue::Title { title, .. } => { + Some(title.into_iter().map(|t| t.plain_text()).collect()) + } + _ => None, + }) + } +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] pub struct Page { pub id: PageId, @@ -180,6 +191,12 @@ pub struct Page { pub parent: Parent, } +impl Page { + pub fn title(&self) -> Option<String> { + self.properties.title() + } +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] pub struct BlockCommon { pub id: BlockId, |