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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bliztek/mdx-utils

v1.0.0

Published

Zero-dependency MDX content utilities for read time calculation and file discovery

Downloads

23

Readme

@bliztek/mdx-utils

Zero-dependency MDX content utilities for read time calculation and file discovery.

Installation

npm install @bliztek/mdx-utils

Usage

Pure Utilities (any JS environment)

import {
  calculateReadTime,
  sortByDateDescending,
  stripMdxSyntax,
} from "@bliztek/mdx-utils";

// Calculate read time from raw MDX content
const { minutes, words } = calculateReadTime(mdxContent);
// => { minutes: 5, words: 1190 }

// Custom words per minute
const { minutes } = calculateReadTime(technicalDoc, { wordsPerMinute: 150 });

// Strip MDX syntax for excerpts, search indexes, or OG descriptions
const plainText = stripMdxSyntax(mdxContent);

// Sort items by date (newest first)
const sorted = sortByDateDescending(posts, (post) => post.date);

Node.js Utilities

import { getContentSlugs, readMdxFile } from "@bliztek/mdx-utils/node";

// Get all MDX slugs from a directory
const slugs = await getContentSlugs("./content/blog");
// => ["my-first-post", "another-post"]

// Include .md files too
const all = await getContentSlugs("./content", {
  extensions: [".mdx", ".md"],
});

// Recursively search nested directories
const nested = await getContentSlugs("./content/blog", { recursive: true });
// => ["my-first-post", "2024/year-in-review"]

// Read an MDX file
const content = await readMdxFile("./content/blog/my-first-post.mdx");

API

calculateReadTime(content, options?)

Calculates estimated read time for MDX/markdown content. Strips export blocks, import statements, JSX tags, and markdown syntax before counting words.

Returns { minutes: number, words: number } — minutes is always at least 1.

| Option | Type | Default | Description | |--------|------|---------|-------------| | wordsPerMinute | number | 238 | Reading speed to use for calculation |

stripMdxSyntax(content)

Strips MDX/markdown syntax from content, returning plain text. Removes export blocks, import statements, JSX tags, and markdown formatting characters. Useful for generating excerpts, search indexes, or OpenGraph descriptions from raw MDX.

sortByDateDescending(items, getDate)

Sorts items by date in descending order (newest first). Returns a new array without mutating the original. The getDate callback should return a date string parseable by new Date().

getContentSlugs(dirPath, options?)

Reads a directory and returns slugs (filenames without extension) of matching content files. When recursive is true, slugs from subdirectories include their relative path (e.g., "2024/my-post").

| Option | Type | Default | Description | |--------|------|---------|-------------| | extensions | string[] | [".mdx"] | File extensions to include | | recursive | boolean | false | Search subdirectories |

readMdxFile(filePath)

Reads a file and returns its content as a UTF-8 string.

Types

type TableOfContentsEntry = { title: string; link: string };
type TableOfContents = TableOfContentsEntry[];

interface ReadTimeOptions { wordsPerMinute?: number }
interface ReadTimeResult { minutes: number; words: number }
interface GetContentSlugsOptions { extensions?: string[]; recursive?: boolean }

Entry Points

| Import | Environment | Contents | |--------|------------|----------| | @bliztek/mdx-utils | Any (browser, edge, Node) | calculateReadTime, stripMdxSyntax, sortByDateDescending, types | | @bliztek/mdx-utils/node | Node.js | getContentSlugs, readMdxFile + re-exports from main |

License

MIT