homepage.js/routes/homepage.js

36 lines
962 B
JavaScript
Raw Normal View History

2023-02-22 08:55:13 +01:00
const Sequelize = require('../models');
2023-03-12 03:28:05 +01:00
const handler = require('express-async-handler');
2023-02-13 02:16:46 +01:00
2023-03-12 03:28:05 +01:00
async function index(req, res) {
2023-02-22 08:55:13 +01:00
let gb_entries = await Sequelize.Guestbook.findAll({
limit: 5,
order: [['id', 'DESC']],
where: { hidden: false }
2023-02-22 08:55:13 +01:00
});
2023-02-27 07:34:08 +01:00
let articles = await Sequelize.Article.findAll({
limit: 5
});
2023-03-05 15:26:56 +01:00
await res.template(
'main.pug',
{
current_route: '/',
gb_entries,
articles,
og: {
title: 'blek! Site',
type: 'website',
image: req.protocol + '://' + req.get('host') + '/content/transylveonia.jpg',
url: req.protocol + '://' + req.get('host') + req.originalUrl
2023-02-18 14:41:24 +01:00
}
2023-03-05 15:26:56 +01:00
}
2023-02-18 14:41:24 +01:00
);
return;
2023-02-13 02:16:46 +01:00
}
module.exports = (router) => {
2023-03-12 03:28:05 +01:00
router.get('/', handler(index));
2023-03-05 15:41:29 +01:00
router.get('/sources', (req, res) => {res.redirect('https://git.blek.codes/blek/homepage.js')});
2023-02-13 02:16:46 +01:00
}