diff options
author | Mark Powers <mark@marks.kitchen> | 2020-12-19 22:35:50 -0600 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2020-12-19 22:35:50 -0600 |
commit | 5a5b666794b688881eb1e1635bf9f2ceb3cc4346 (patch) | |
tree | 4b80da46e9ea1d6ada7df0792a46640de065d8a7 /src/server.js | |
parent | c18dd9ef6c9b3407862db7f01372bc65bb1c3721 (diff) |
Add title to posts
Diffstat (limited to 'src/server.js')
-rw-r--r-- | src/server.js | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/src/server.js b/src/server.js index 2198923..81b7b0e 100644 --- a/src/server.js +++ b/src/server.js @@ -50,43 +50,6 @@ function hashWithSalt(password, salt){ return hash.digest("base64"); }; -function constructFeed(posts){ - var html = [] - html.push(`<div class="feed">`) - posts.forEach(post => { - html.push(`<div class="card"> - <p class="card-text">${post.description}</p> - <div class="card-img">`) - post.images.forEach(image => { - html.push(`<span> - <a href="/${image}"><img src="/${image}"></a> - </span>`) - }) - html.push(`</div> - <p class="date"> - <a href="/post/${post.type}/${post.id}">${post.createdAt.toString().substring(0,10)}</a>`) - post.tags.forEach(tag => { - html.push(`<span> - <a class="tag" href="/tags/${tag}">${tag}</a> - </span>`) - }) - html.push(`</p> - </div>`) - }) - html.push(`</div>`) - return html.join(""); -} - -async function constructFeedFromType(models, postType){ - var posts = await models.posts.findAll({ - where: { type: postType }, order: [['createdAt', 'DESC']] - }); - posts = posts.map(x => x.get({ plain: true })); - await addImagesAndTagsToPosts(models, posts) - - return constructFeed(posts) -} - async function formatPostsforSingle(models, postType, postId){ var posts = await models.posts.findAll({ where: { @@ -110,6 +73,7 @@ async function formatPostsForType(models, postType){ await addImagesAndTagsToPosts(models, posts) posts.forEach(post => { post.createdAt = post.createdAt.toString().substring(0, 10) + post.showTitle = post.type != "bread" }) return posts; } @@ -384,7 +348,7 @@ function setUpRoutes(models, jwtFunctions, database, templates) { posts = posts.map(x => x.get({ plain: true })); posts.forEach(post =>{ feed.item({ - title: post.createdAt.toString().substring(0, post.createdAt.toString().indexOf(" GMT")), + title: post.title, description: post.description, date: post.createdAt, url: `https://marks.kitchen/post/${post.type}/${post.id}`, |