diff options
| author | Bobby <[email protected]> | 2022-03-19 22:18:42 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-03-19 22:18:42 -0400 |
| commit | 51b01007881b25958577341f6398b04beca82dcb (patch) | |
| tree | b9786ae042fddb536d8a6f7f36d57931e4a09e76 /routes/posts.js | |
| parent | fce830d22c88304f2aa4ece29aa112a51ef224ba (diff) | |
| download | luciferreeves.github.io-51b01007881b25958577341f6398b04beca82dcb.tar.xz luciferreeves.github.io-51b01007881b25958577341f6398b04beca82dcb.zip | |
Added post to main page + posts page
Diffstat (limited to 'routes/posts.js')
| -rw-r--r-- | routes/posts.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/routes/posts.js b/routes/posts.js index 3ae3a3c..7e68106 100644 --- a/routes/posts.js +++ b/routes/posts.js @@ -6,21 +6,18 @@ router.get("/posts", (req, res) => { const store = firebase.firestore(); const posts = []; let query = store.collection("posts"); - - query - .get() - .then((querySnapshot) => { - querySnapshot.forEach((documentSnapshot) => { - posts.push(documentSnapshot.data()); - }); - }) - .then(() => { - res.json(posts); + query = query.select("slug", "tags", "title", "shortText", "publishDate"); + query.get().then(function (querySnapshot) { + querySnapshot.forEach(function (doc) { + posts.push(doc.data()); }); + }).then(() => { + res.json(posts); + }); }); router.post("/new", (req, res) => { - const { title, content, tags, publishDate } = req.body; + const { title, content, tags, publishDate, shortText, slug } = req.body; const store = firebase.firestore(); const id = store.collection("posts").doc().id; const post = { @@ -29,6 +26,8 @@ router.post("/new", (req, res) => { content, tags: String(tags).split(",").length > 0 ? String(tags).split(",") : [], publishDate, + shortText, + slug, }; let query = store.collection("posts"); query |
