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

@jk2908/mdsrc

v0.2.0

Published

A Vite plugin for turning structured Markdown content into importable, type-safe modules

Readme

@jk2908/mdsrc

A Vite plugin for managing markdown content with type safety.

Install

npm install @jk2908/mdsrc

Usage

import plugin from '@jk2908/mdsrc'
import comark from '@comark/markdown-it'
import { defineConfig } from 'vite'

export default defineConfig({
	plugins: [
		plugin({
			plugins: [comark],
			collections: [
				{
					dir: 'content',
					name: 'post',
					schema: {
						title: { type: 'string' },
					},
				},
			],
		}),
	],
})

The plugin reads markdown content, validates frontmatter against your schema, and generates typed modules during build and watch. Root config uses collections, optional plugins, and logger. Collection config uses name, dir, and schema.

Each entry exports both html and markdown.

  • html is rendered with markdown-it, with hard line breaks preserved.
  • Raw HTML is escaped by default because the renderer runs with html: false.
  • markdown preserves the original body for custom renderers like @comark/react.

Root plugins accepts markdown-it plugins directly or tuples like [plugin, ...args] and applies them to every collection.

See examples/basic for the default HTML output flow and examples/components for the shared @comark/markdown-it plugin used with React.

If you configure a collection with name: 'post', mdsrc exposes allPosts from the package root.

import { allPosts } from '@jk2908/mdsrc'

export const summaries = allPosts.map(post => ({
	title: post.title,
	slug: post.__mdsrc.slug,
	html: post.html,
	markdown: post.markdown,
}))

If you want the generated collection module directly, you can also import the collection subpath.

import { allPosts } from '@jk2908/mdsrc/post'

The generated files live in ./.mdsrc on disk, so you can import them directly via paths like ./.mdsrc/index.js, but .mdsrc itself is not a module ID the plugin resolves. The stable import IDs are @jk2908/mdsrc and @jk2908/mdsrc/<collection>.

License

MIT