@@ -3,7 +3,7 @@ use notion_client::endpoints::{
3
3
Client ,
4
4
} ;
5
5
use chrono:: { DateTime , NaiveDate , Utc } ;
6
- use notion_client:: objects:: parent;
6
+ use notion_client:: objects:: { parent, rich_text } ;
7
7
use notion_client:: {
8
8
objects:: page:: Page ,
9
9
objects:: page:: PageProperty ,
@@ -26,25 +26,31 @@ impl PageWithBlocks {
26
26
// The properties are separated by a newline character.
27
27
// Currently, only the title and rich_text properties are supported.
28
28
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 ( ) ;
30
31
for ( k, v) in self . page . properties . iter ( ) {
31
32
match v {
32
33
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
+ }
37
41
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 ) ;
44
48
}
49
+ _ => { }
45
50
}
46
51
}
47
- return res. join ( "\n " ) ;
52
+ title_vec. extend ( rich_text_vec) ;
53
+ return title_vec. join ( "\n " ) ;
48
54
}
49
55
50
56
// dfs returns content in depth-first order.
0 commit comments