diff --git a/includes/html/footer.html b/includes/html/footer.html index 22c86fe..b97435b 100644 --- a/includes/html/footer.html +++ b/includes/html/footer.html @@ -59,7 +59,9 @@ diff --git a/includes/html/header.html b/includes/html/header.html index a3d27d5..0602309 100644 --- a/includes/html/header.html +++ b/includes/html/header.html @@ -65,6 +65,9 @@ + diff --git a/routes/api/index.js b/routes/api/index.js index 32508cc..559368b 100644 --- a/routes/api/index.js +++ b/routes/api/index.js @@ -1,19 +1,35 @@ const routes = require('express').Router(); const sql = require('../../utils/sql'); - +const renderPost = require('../../blog/renderBlogPost'); routes.get('/posts', (request, result) => { sql.getAllPosts().then((data)=> { - result.json(data).end();result + result.json(data).end(); }).catch((err)=> { result.status(500).json([]).end(); }); }); + +routes.get('/render/:postID', (request, result) => +{ + sql.getPostById(request.params.postID).then((sqlData)=> + { + renderPost.generateBlogPost(sqlData, -1).then((rendered)=> + { + result.json(rendered).end(); + }); + }).catch((err)=> + { + result.status(404).json({error: 404}).end(); + }) + +}); + routes.get('*', (request, result) => { result.json([]).end(); diff --git a/templates/blog/posts.html b/templates/blog/posts.html index db81b34..565847b 100644 --- a/templates/blog/posts.html +++ b/templates/blog/posts.html @@ -78,9 +78,19 @@
-
-
+
+
+
+ +
+

+
+
+
+
+
+


@@ -95,7 +105,9 @@