From 6b2c2cc60b85bbdb43a352a9e742e581511723c0 Mon Sep 17 00:00:00 2001 From: Bram Dingelstad <git@dingelstad.works> Date: Sat, 15 Mar 2025 22:16:53 +0100 Subject: [PATCH] feat: added caption for video BlockType chore: updated to newer version of notion-client --- src/lib.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 11ec212..a3e76a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -168,9 +168,29 @@ pub async fn convert_blocks( } BlockType::Video { video, .. } => { match &video { - notion::File::External { external, .. } => { + notion::File::External { + external, caption, .. + } => { let url = &external.url; - Some(format!(r#"<video controls src="{url}" />"#)) + + let caption = if let Some(caption) = caption { + format!( + "<figcaption>{text}</figcaption>", + text = &caption + .iter() + .map(|rich_text| rich_text.plain_text()) + .collect::<String>() + ) + } else { + "".to_string() + }; + + Some(format!( + r#"<figure> + <video controls src="{url}"></video> + {caption} + </figure>"# + )) } // TODO: Implement reupload of Notion file type _ => None, @@ -184,7 +204,7 @@ pub async fn convert_blocks( BlockType::ColumnList { .. } => { if block.has_children { let columns = notion - .blocks + .blocks() .children() .list(notion::BlockChildrenListOptions { block_id: &block.id, @@ -196,7 +216,7 @@ pub async fn convert_blocks( let mut content = vec![]; for column in columns.iter() { let children = notion - .blocks + .blocks() .children() .list(notion::BlockChildrenListOptions { block_id: &column.id,