@@ -38,33 +38,39 @@ async function main() {
38
38
"utf-8" ,
39
39
) ;
40
40
41
- const { source, content, data } = await parseMarkdown ( { markdown : blog } ) ;
41
+ const { source, content, data } = parseMarkdown ( { markdown : blog } ) ;
42
42
43
43
if ( ! blogExists ) {
44
- await firestore . collection ( "blogs" ) . doc ( fileNameWithoutExtension ) . set (
45
- {
46
- source,
47
- content : content ,
48
- data,
49
- dateCreated : data . dateCreated . toUTCString ( ) ,
50
- dateUpdated : new Date ( ) . toUTCString ( ) ,
51
- likes : 0 ,
52
- link : fileNameWithoutExtension ,
53
- } ,
54
- { merge : true } ,
55
- ) ;
44
+ await firestore
45
+ . collection ( "blogs" )
46
+ . doc ( fileNameWithoutExtension )
47
+ . set (
48
+ {
49
+ source,
50
+ content :content ,
51
+ ...data ,
52
+ dateCreated : blogMatter . data . dateCreated . toUTCString ( ) ,
53
+ dateUpdated : new Date ( ) . toUTCString ( ) ,
54
+ likes : 0 ,
55
+ link : fileNameWithoutExtension ,
56
+ } ,
57
+ { merge : true } ,
58
+ ) ;
56
59
} else {
57
- await firestore . collection ( "blogs" ) . doc ( fileNameWithoutExtension ) . set (
58
- {
59
- source,
60
- content : content ,
61
- data,
62
- dateCreated : data . dateCreated . toUTCString ( ) ,
63
- dateUpdated : new Date ( ) . toUTCString ( ) ,
64
- link : fileNameWithoutExtension ,
65
- } ,
66
- { merge : true } ,
67
- ) ;
60
+ await firestore
61
+ . collection ( "blogs" )
62
+ . doc ( fileNameWithoutExtension )
63
+ . set (
64
+ {
65
+ source,
66
+ content : content ,
67
+ ...data ,
68
+ dateCreated : blogMatter . data . dateCreated . toUTCString ( ) ,
69
+ dateUpdated : new Date ( ) . toUTCString ( ) ,
70
+ link : fileNameWithoutExtension ,
71
+ } ,
72
+ { merge : true } ,
73
+ ) ;
68
74
}
69
75
}
70
76
}
0 commit comments