A powerful and lightweight npm package for working with structured blog post data, featuring 200+ dummy posts out of the box. Includes built-in pagination, categorization, fuzzy search, and full TypeScript support. Perfect for static blogs, CMS backends, or frontend demos.
Note
π 200+ Posts and 30 Categories with SEO Meta!
- π Pagination β Retrieve posts with configurable page size and pagination
- π·οΈ Category Filtering β Organize and access posts by categories
- π Search β Fuzzy search powered by Fuse.js
- π Post Slug Lookup β Quickly fetch posts by slug
- π§© Modular API β Simple, composable utilities
- β‘ Lightweight β Zero bloat, minimal dependencies
- π§ Fully Typed β Built with TypeScript for great DX
npm install best-blog-data
or
pnpm add best-blog-data
import BestBlogData from 'best-blog-data'
const blogData = new BestBlogData()
const { posts, nextPageAvailable } = blogData.getPosts() // Defaults to page 1
console.log(posts.length) // Up to 10 posts
const page2 = blogData.getPosts(2)
console.log(page2.posts.length)
const post = blogData.getFullPostBySlug('my-blog-post-slug')
if (post) {
console.log(post.title)
}
const { posts, nextPageAvailable, categoryFound } =
blogData.getPostsByCategory('technology')
if (categoryFound) {
console.log(posts)
}
const reactPostsPage2 = blogData.getPostsByCategory('react', 2)
const categories = blogData.getAllCategories()
console.log(categories)
// [
// { slug: 'react', name: 'React' },
// { slug: 'ai', name: 'Artificial Intelligence' },
// ...
// ]
const searchResults = blogData.getPostsBySearch('AI content')
searchResults.forEach(({ item, score }) => {
console.log(`${item.title} (score: ${score})`)
})
Returns paginated posts (10 per page by default).
Fetch a single post by its unique slug.
blogData.getPostsByCategory(categorySlug: string, pageIndex?: number): { posts: Post[], nextPageAvailable: boolean, categoryFound: boolean }
Retrieve posts filtered by a category slug.
Returns a list of all unique categories found in posts.
Performs fuzzy search across post titles. Returns max 10 results with match scores.
interface Post {
slug: string
title: string
content?: string
date: string
image: string
categorie: {
slug: string
name: string
}
meta_seo: {
title: string
description: string
image: string
url: string
}
}
interface Category {
slug: string
name: string
}
- Threshold:
0.3
- Search Keys:
['title']
- Limit:
10 results
fuse.js
β Fuzzy search engine
- Build static blog websites
- Power blog UIs with real or mock content
- CMS & content preview tools
- Search-enabled article listings
- Prototyping frontend blog layouts
This package is fully typed with built-in definitions, ensuring IntelliSense and compile-time safety in modern editors and TypeScript projects.
Found a bug or have a feature idea? PRs and issues are welcome!
git clone https://github.com/devgauravjatt/best-blog-data
MIT Β© devgauravjatt
blog
, cms
, posts
, pagination
, search
, categories
, typescript
, fuse
, content
, npm-package