2024-04-29 14:58:42 +01:00
|
|
|
var express = require("express");
|
|
|
|
const axios = require("axios");
|
2020-06-22 20:36:41 +01:00
|
|
|
var router = express.Router();
|
|
|
|
|
|
|
|
/* GET home page. */
|
2024-04-29 13:21:31 +01:00
|
|
|
router.get('/', function (req, res, _next) {
|
|
|
|
const GHOST_KEY = process.env.GHOST_KEY;
|
|
|
|
const base_url = `https://blog.pastel.codes/ghost/api/v3/content/posts/?key=${GHOST_KEY}`;
|
2020-06-27 17:46:21 +01:00
|
|
|
|
2024-04-29 13:21:31 +01:00
|
|
|
axios
|
|
|
|
.all([
|
|
|
|
axios.get(`${base_url}&limit=3`),
|
|
|
|
axios.get(`${base_url}&limit=3&filter=tag:project`),
|
2020-06-27 17:46:21 +01:00
|
|
|
])
|
2024-04-29 13:21:31 +01:00
|
|
|
.then(
|
|
|
|
axios.spread((response1, response2) => {
|
|
|
|
var base = {
|
|
|
|
title: 'About',
|
|
|
|
description: 'Who??? What??? AAAAaaa, about me.',
|
|
|
|
};
|
|
|
|
var blog = JSON.parse(
|
|
|
|
JSON.stringify(response1.data).split('"posts":').join('"blog":')
|
|
|
|
);
|
|
|
|
var projects = JSON.parse(
|
|
|
|
JSON.stringify(response2.data).split('"posts":').join('"project":')
|
|
|
|
);
|
|
|
|
var out = Object.assign(base, blog, projects);
|
2020-06-27 17:46:21 +01:00
|
|
|
|
2024-04-29 13:21:31 +01:00
|
|
|
res.render('about', out);
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.catch((error) => {
|
2024-04-29 14:58:42 +01:00
|
|
|
var base = {
|
|
|
|
title: 'About',
|
|
|
|
description: 'Who??? What??? AAAAaaa, about me.',
|
|
|
|
};
|
|
|
|
var out = Object.assign(base);
|
|
|
|
console.log('error', error);
|
|
|
|
res.render('about', out);
|
2024-04-29 13:21:31 +01:00
|
|
|
});
|
2020-06-22 20:36:41 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|