Posts

Read published blog content: paginated lists, single posts, full archives, and slug lists for static generation.

Methods

nf.posts.list(params?)     // List posts (paginated)
nf.posts.get(slug, opts?)  // Single post with full content
nf.posts.all(params?)      // ALL posts (auto-paginated)
nf.posts.slugs()           // All slugs (SSG / generateStaticParams)
nf.posts.iter(params?)    // Async iterator over every post

List & get options

List params: page, limit, tag, category, sort ("newest" | "oldest")

Get options: format ("html" | "markdown"), styled (boolean)

Examples

Blog index with pagination

blog-index.ts
const { data } = await nf.posts.list({ limit: 12, category: "engineering" })

for (const post of data.posts) {
  console.log(`${post.title} - ${post.excerpt}`)
}

if (data.pagination.hasMore) {
  const { data: page2 } = await nf.posts.list({ limit: 12, page: 2 })
}

Static site generation - all slugs

slugs.ts
const slugs = await nf.posts.slugs()
// [{ slug: "intro-to-nextjs" }, { slug: "deploy-to-vercel" }, ...]

Async iterator - every post without manual pages

iterate.ts
for await (const post of nf.posts.iter({ category: "news" })) {
  console.log(post.title)
}