Commit 353fb162 authored by Jarrod's avatar Jarrod 💬

Add recent posts to single post endpoint

parent d5e6bcb2
......@@ -14,16 +14,31 @@ module.exports = {
fn: async function (inputs) {
const post = await BlogPost.find({
const post = await BlogPost.findOne({
published: true,
slug: inputs.slug
.select(['id', 'title', 'excerpt', 'body', 'featureImage', 'createdAt'])
.select(['id', 'slug', 'title', 'excerpt', 'body', 'featureImage', 'createdAt'])
if (!post) {
return this.res.notFound('Post not found')
const recentPosts = await BlogPost.find({
published: true,
slug: inputs.slug,
id: { '!=': }
.select(['id', 'slug', 'title', 'excerpt', 'featureImage', 'createdAt'])
.sort('createdAt DESC')
// All done.
return {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment