add guestbook records to index page

This commit is contained in:
b1ek 2023-02-22 17:55:13 +10:00
parent 2bc7d847f3
commit 7294210821
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 17 additions and 8 deletions

View File

@ -1,11 +1,19 @@
const Helpers = require('../helpers'); const Helpers = require('../helpers');
const Sequelize = require('../models');
async function handler(req, res) { async function handler(req, res) {
let gb_entries = await Sequelize.Guestbook.findAll({
limit: 5,
order: [['id', 'DESC']]
});
res.send( res.send(
await Helpers.ViewLoader.load( await Helpers.ViewLoader.load(
'main.pug', 'main.pug',
{ {
current_route: '/' current_route: '/',
gb_entries
} }
) )
); );

View File

@ -24,12 +24,13 @@ block content
| ( | (
a(href='/guestbook.rss') RSS a(href='/guestbook.rss') RSS
| ) | )
ul if (gb_entries)
li entry ul(style='margin:0 10px;padding:0')
li entry each entry in gb_entries
li entry li(style='padding-bottom:10px')
li entry | #{entry.name} says:
li entry br
| #{entry.text}
a(href='/guestbook') Write something in my guestbook! a(href='/guestbook') Write something in my guestbook!
td(width='50%' style='border-left:1px solid #c2c4c2;border-right:1px solid #c2c4c2;padding:0 1%') td(width='50%' style='border-left:1px solid #c2c4c2;border-right:1px solid #c2c4c2;padding:0 1%')
h3 Blog h3 Blog