Skip to content

Commit 534ebe3

Browse files
committed
Update: spread data instead of creating object
1 parent ae345a5 commit 534ebe3

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

publish/index.js

+30-24
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,39 @@ async function main() {
3838
"utf-8",
3939
);
4040

41-
const { source, content, data } = await parseMarkdown({ markdown: blog });
41+
const { source, content, data } = parseMarkdown({ markdown: blog });
4242

4343
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+
);
5659
} 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+
);
6874
}
6975
}
7076
}

0 commit comments

Comments
 (0)