const apiUrl = 'https://your-ghost-blog-url.com/ghost/api/content/posts/'; const apiKey = 'your-content-api-key'; async function getNextPost(currentPostId, currentPostDate) { const response = await fetch(`${apiUrl}?key=${apiKey}&filter=published_at:>${currentPostDate}&limit=1&order=published_at asc`); const data = await response.json(); return data.posts[0]; // This will be the next post } // Example Usage const nextPost = await getNextPost(currentPostId, currentPostDate); console.log('Next Post:', nextPost);
const response = await fetch(`${apiUrl}?key=${apiKey}&filter=published_at:>${currentPostDate}&fields=slug,url&limit=1&order=published_at asc`);
fetch
which is eseentially the same thing as our URL field in resources`${apiUrl}?key=${apiKey}&filter=published_at:>${currentPostDate}&limit=1&order=published_at asc`