@@ -13,44 +13,50 @@ exports.sourceNodes = async (
13
13
}
14
14
15
15
data . pages . forEach ( ( page ) => {
16
- const properties = Object . keys ( page . properties ) . reduce (
17
- ( acc , key ) =>
18
- acc . concat ( [
19
- {
20
- key,
21
- ...page . properties [ key ] ,
22
- } ,
23
- ] ) ,
24
- [ ] ,
16
+ const properties = Object . keys ( page . properties ) . reduce ( ( acc , key ) => {
17
+ if ( page . properties [ key ] . type == "title" ) {
18
+ return acc
19
+ }
20
+
21
+ return {
22
+ ...acc ,
23
+ [ key ] : {
24
+ key,
25
+ value : page . properties [ key ] [ page . properties [ key ] . type ] ,
26
+ type : page . properties [ key ] . type ,
27
+ } ,
28
+ }
29
+ } , { } )
30
+
31
+ const titleProperty = Object . keys ( page . properties ) . find (
32
+ ( key ) => page . properties [ key ] . type == "title" ,
25
33
)
26
34
27
- const title = properties
28
- . find ( ( property ) => property . type == "title" )
29
- . title . reduce ( ( acc , chunk ) => {
30
- if ( chunk . type == "text" ) {
31
- return acc . concat ( chunk . plain_text )
35
+ const title = page . properties [ titleProperty ] . title . reduce ( ( acc , chunk ) => {
36
+ if ( chunk . type == "text" ) {
37
+ return acc . concat ( chunk . plain_text )
38
+ }
39
+
40
+ if ( chunk . type == "mention" ) {
41
+ if ( chunk . mention . type == "user" ) {
42
+ return acc . concat ( chunk . mention . user . name )
32
43
}
33
44
34
- if ( chunk . type == "mention " ) {
35
- if ( chunk . mention . type == "user" ) {
36
- return acc . concat ( chunk . mention . user . name )
45
+ if ( chunk . mention . type == "date " ) {
46
+ if ( chunk . mention . date . end ) {
47
+ return acc . concat ( ` ${ chunk . mention . date . start } → ${ chunk . mention . date . start } ` )
37
48
}
38
49
39
- if ( chunk . mention . type == "date" ) {
40
- if ( chunk . mention . date . end ) {
41
- return acc . concat ( `${ chunk . mention . date . start } → ${ chunk . mention . date . start } ` )
42
- }
43
-
44
- return acc . concat ( chunk . mention . date . start )
45
- }
50
+ return acc . concat ( chunk . mention . date . start )
51
+ }
46
52
47
- if ( chunk . mention . type == "page" ) {
48
- return acc . concat ( chunk . plain_text )
49
- }
53
+ if ( chunk . mention . type == "page" ) {
54
+ return acc . concat ( chunk . plain_text )
50
55
}
56
+ }
51
57
52
- return acc
53
- } , "" )
58
+ return acc
59
+ } , "" )
54
60
55
61
createNode ( {
56
62
id : createNodeId ( `${ NODE_TYPE } -${ page . id } ` ) ,
0 commit comments