npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

express-markdown-blog-middleware

v1.1.0

Published

Express middleware for rendering markdown blog posts with pagination

Readme

Express Markdown Blog Middleware

Express middleware for rendering markdown blog posts with pagination.

Features

  • Markdown blog post rendering with HTML output
  • Blog utilities for easy post management
  • Cache support
  • TypeScript support
  • API endpoints for posts
  • Tag support

Installation

npm install express-markdown-blog-middleware

Quick Start

const express = require('express');
const path = require('path');
const createBlogMiddleware = require('express-markdown-blog-middleware');

const app = express();

// Initialize blog middleware
app.use(createBlogMiddleware(path.join(__dirname, 'content')));

// Use blog utilities
app.get('/api/posts', (req, res) => {
  const posts = req.blog.getAllPosts();
  res.json(posts);
});

app.get('/api/posts/:slug', (req, res) => {
  const post = req.blog.getPost(req.params.slug);
  if (!post) return res.status(404).json({ error: 'Post not found' });
  res.json(post);
});

app.listen(3000);

Directory Structure

your-project/
  └── content/           # Markdown blog posts
      ├── post-1.md
      └── post-2.md

Blog Post Format

---
title: My First Post
date: 2024-03-15
description: This is my first blog post
keywords: [blog, first post]
lang: en
---

# My First Post

Blog post content here...

Blog Utils

The middleware adds blog utilities to the request object:

// Get all posts in English
const posts = req.blog.getPostsByLang('en');

// Get paginated posts in Turkish
const posts = req.blog.getPaginatedPosts(1, 10, 'tr');

// Get single post in Spanish
const post = req.blog.getPost('post-slug', 'es');

// Get posts by tag in German
const posts = req.blog.getPostsByTag('javascript', 'de');

Configuration Options

createBlogMiddleware(contentDir, {
  // Cache duration in ms (default: 5 minutes)
  cacheMaxAge: 5 * 60 * 1000
});

TypeScript Support

Types are included and will be automatically available when using TypeScript.

import { Request } from 'express';

interface BlogPost {
  title: string;
  date: string;
  description?: string;
  keywords?: string[];
  content: string;
  slug: string;
}

// Blog utilities are typed
app.get('/posts', (req: Request, res) => {
  const posts: BlogPost[] = req.blog.getAllPosts();
  res.json(posts);
});

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.