Skip to content

Commit ba4036e

Browse files
author
leili
committed
ensure the 'title' is before 'description'
1 parent a2632ff commit ba4036e

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

ee/tabby-webserver/src/service/background_job/notion/notion_util.rs

+19-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use notion_client::endpoints::{
33
Client,
44
};
55
use chrono::{DateTime, NaiveDate, Utc};
6-
use notion_client::objects::parent;
6+
use notion_client::objects::{parent, rich_text};
77
use notion_client::{
88
objects::page::Page,
99
objects::page::PageProperty,
@@ -26,25 +26,31 @@ impl PageWithBlocks {
2626
// The properties are separated by a newline character.
2727
// Currently, only the title and rich_text properties are supported.
2828
fn page_properties(&self) -> String {
29-
let mut res = Vec::new();
29+
let mut title_vec = Vec::new();
30+
let mut rich_text_vec = Vec::new();
3031
for (k, v) in self.page.properties.iter() {
3132
match v {
3233
PageProperty::Title { title, .. } => {
33-
res.push(k.clone());
34-
let s = title.iter().map(|t| t.plain_text()).filter_map(|text| text).collect::<Vec<String>>().join(" ");
35-
res.push(s);
36-
},
34+
let s = title.iter()
35+
.filter_map(|t| t.plain_text())
36+
.collect::<Vec<_>>()
37+
.join(" ");
38+
title_vec.push(k.to_string());
39+
title_vec.push(s);
40+
}
3741
PageProperty::RichText { rich_text, .. } => {
38-
res.push(k.clone());
39-
let s = rich_text.iter().map(|t| t.plain_text()).filter_map(|text| text).collect::<Vec<String>>().join(" ");
40-
res.push(s);
41-
},
42-
_ => {
43-
42+
let s = rich_text.iter()
43+
.filter_map(|t| t.plain_text())
44+
.collect::<Vec<_>>()
45+
.join(" ");
46+
rich_text_vec.push(k.to_string());
47+
rich_text_vec.push(s);
4448
}
49+
_ => {}
4550
}
4651
}
47-
return res.join("\n");
52+
title_vec.extend(rich_text_vec);
53+
return title_vec.join("\n");
4854
}
4955

5056
// dfs returns content in depth-first order.

0 commit comments

Comments
 (0)