Skip to content
Discussion options

You must be logged in to vote

For those who want to get their articles, in API routes you can use the serverQueryContent API function provided by the #content/server
This is a sample, I used on my blog that way I can use it to show to my portfolio website.

// server/api/recent-contents/ts
import { serverQueryContent } from "#content/server";

export default defineEventHandler(async (event) => {
    // Fetch all documents
    const docs = await serverQueryContent(event).limit(10).find();
    const baseUrl = "https://bro.brojenuel.com";
    return docs.map((doc) => {
        return {
            path: `${baseUrl}${doc._path}`,
            title: doc.title,
            description: doc.description,
            keywords: doc

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@JenuelDev
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by JenuelDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants