feat: added support for links in RichText and Embeds
This commit is contained in:
parent
15e2c510ee
commit
03c3b887b1
17
src/lib.rs
17
src/lib.rs
|
@ -9,7 +9,10 @@ use notion::BlockType;
|
|||
pub fn convert_rich_text(text: ¬ion::RichText) -> String {
|
||||
match text {
|
||||
notion::RichText::Text {
|
||||
text, annotations, ..
|
||||
text,
|
||||
annotations,
|
||||
href,
|
||||
..
|
||||
} => {
|
||||
let mut string = text.content.to_owned();
|
||||
|
||||
|
@ -25,6 +28,10 @@ pub fn convert_rich_text(text: ¬ion::RichText) -> String {
|
|||
string = format!("`{string}`");
|
||||
}
|
||||
|
||||
if let Some(url) = href {
|
||||
string = format!("[{string}]({url})");
|
||||
}
|
||||
|
||||
string
|
||||
}
|
||||
_ => "".to_string(),
|
||||
|
@ -214,6 +221,13 @@ pub async fn convert_blocks(
|
|||
}
|
||||
}
|
||||
|
||||
BlockType::Embed { embed } => {
|
||||
let url = &embed.url;
|
||||
Some(format!(
|
||||
r#"<iframe width="100%" height="420px" src="{url}"></iframe>"#
|
||||
))
|
||||
}
|
||||
|
||||
BlockType::Column { .. }
|
||||
| BlockType::Table
|
||||
| BlockType::Bookmark { .. }
|
||||
|
@ -226,7 +240,6 @@ pub async fn convert_blocks(
|
|||
| BlockType::Template
|
||||
| BlockType::Toggle
|
||||
| BlockType::Breadcrumb
|
||||
| BlockType::Embed { .. }
|
||||
| BlockType::Equation { .. }
|
||||
| BlockType::LinkPreview { .. }
|
||||
| BlockType::TableRow
|
||||
|
|
Loading…
Reference in a new issue