aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server.js b/src/server.js
index 81b7b0e..81f1edb 100644
--- a/src/server.js
+++ b/src/server.js
@@ -50,6 +50,11 @@ function hashWithSalt(password, salt){
return hash.digest("base64");
};
+function formatDate(d) {
+ let month = d.toLocaleString('default', { month: 'long' });
+ return month + " " + d.getDate() + ", " + (1900+d.getYear())
+}
+
async function formatPostsforSingle(models, postType, postId){
var posts = await models.posts.findAll({
where: {
@@ -60,7 +65,8 @@ async function formatPostsforSingle(models, postType, postId){
posts = posts.map(x => x.get({ plain: true }));
await addImagesAndTagsToPosts(models, posts)
posts.forEach(post => {
- post.createdAt = post.createdAt.toString().substring(0, 10)
+ post.createdAt = formatDate(post.createdAt)
+ post.showTitle = post.type != "bread"
})
return posts
}
@@ -72,7 +78,7 @@ async function formatPostsForType(models, postType){
posts = posts.map(x => x.get({ plain: true }));
await addImagesAndTagsToPosts(models, posts)
posts.forEach(post => {
- post.createdAt = post.createdAt.toString().substring(0, 10)
+ post.createdAt = formatDate(post.createdAt)
post.showTitle = post.type != "bread"
})
return posts;