From 87ab783dc3af612263939d53b3f3ae3706fae401 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Wed, 17 Jun 2020 20:24:44 -0400 Subject: [PATCH] added more posts and functionality to load previews --- routes/api/index.js | 16 ++++- templates/blog/blogMain.html | 125 ++++++++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 2 deletions(-) diff --git a/routes/api/index.js b/routes/api/index.js index 559368b..852ae85 100644 --- a/routes/api/index.js +++ b/routes/api/index.js @@ -15,6 +15,21 @@ routes.get('/posts', (request, result) => }); +routes.get('/preview/:postID', (request, result) => +{ + sql.getPostById(request.params.postID).then((sqlData)=> + { + renderPost.generateBlogPost(sqlData, 3).then((rendered)=> + { + result.json(rendered).end(); + }); + }).catch((err)=> + { + result.status(404).json({error: 404}).end(); + }) +}); + + routes.get('/render/:postID', (request, result) => { sql.getPostById(request.params.postID).then((sqlData)=> @@ -27,7 +42,6 @@ routes.get('/render/:postID', (request, result) => { result.status(404).json({error: 404}).end(); }) - }); routes.get('*', (request, result) => diff --git a/templates/blog/blogMain.html b/templates/blog/blogMain.html index 8657082..de4c18c 100644 --- a/templates/blog/blogMain.html +++ b/templates/blog/blogMain.html @@ -1,4 +1,116 @@ {>header} + + + + +




@@ -40,7 +152,18 @@

{/for} - {>paginationTemplate} +
+ + {if preview} +
+
+

+ More Posts » +

+
+
+ {/if}