feat: added caption for video BlockType
chore: updated to newer version of notion-client
This commit is contained in:
parent
03c3b887b1
commit
6b2c2cc60b
1 changed files with 24 additions and 4 deletions
28
src/lib.rs
28
src/lib.rs
|
@ -168,9 +168,29 @@ pub async fn convert_blocks(
|
||||||
}
|
}
|
||||||
BlockType::Video { video, .. } => {
|
BlockType::Video { video, .. } => {
|
||||||
match &video {
|
match &video {
|
||||||
notion::File::External { external, .. } => {
|
notion::File::External {
|
||||||
|
external, caption, ..
|
||||||
|
} => {
|
||||||
let url = &external.url;
|
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
|
// TODO: Implement reupload of Notion file type
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -184,7 +204,7 @@ pub async fn convert_blocks(
|
||||||
BlockType::ColumnList { .. } => {
|
BlockType::ColumnList { .. } => {
|
||||||
if block.has_children {
|
if block.has_children {
|
||||||
let columns = notion
|
let columns = notion
|
||||||
.blocks
|
.blocks()
|
||||||
.children()
|
.children()
|
||||||
.list(notion::BlockChildrenListOptions {
|
.list(notion::BlockChildrenListOptions {
|
||||||
block_id: &block.id,
|
block_id: &block.id,
|
||||||
|
@ -196,7 +216,7 @@ pub async fn convert_blocks(
|
||||||
let mut content = vec![];
|
let mut content = vec![];
|
||||||
for column in columns.iter() {
|
for column in columns.iter() {
|
||||||
let children = notion
|
let children = notion
|
||||||
.blocks
|
.blocks()
|
||||||
.children()
|
.children()
|
||||||
.list(notion::BlockChildrenListOptions {
|
.list(notion::BlockChildrenListOptions {
|
||||||
block_id: &column.id,
|
block_id: &column.id,
|
||||||
|
|
Loading…
Reference in a new issue