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

walkcontent

v0.4.0

Published

A CLI to recursively walk markdown content directories, parse each file's metadata, and write a JSON map of file path to that metadata.

Readme

walkcontent

A CLI to recursively walk markdown content directories (for example, your static site blog), parse each file's metadata, and write a JSON map of file path to that metadata. Intended for use with tools such as sitemap generators, URL mappers, etc.

The following data is extracted from each file:

  • Top-level heading, $h1
  • Date from file path, $date
  • File modification time, $mtime
  • Line number where content starts (after the frontmatter block, if any), $contentStart
  • YAML frontmatter block, flattened into key-value pairs added directly to the output
  • With --include-content: every heading ($headings) and link ($links) found in the file, in document order

Example

Example content and output of running walkcontent - same as text written next

For a given input directory structure like this:

content
├── blog
│   └── 2024-02-01
│       └── index.md
└── posts
    ├── 2024-01-15-hello-world.md
    └── drafts
        └── unpublished-post.md
mkdir -p content/posts/drafts content/blog/2024-02-01

cat <<'EOF' > content/posts/2024-01-15-hello-world.md
---
title: Hello World
tags: [intro]
---
# Hello World

Welcome to my blog.
EOF

cat <<'EOF' > content/posts/drafts/unpublished-post.md
---
title: Draft
---
# Draft Post

Still being written.
EOF

cat <<'EOF' > content/blog/2024-02-01/index.md
---
author: Jane Doe
---
# Second Post

More content.
EOF

Run walkcontent with the -d flag to walk the content directory. Passing posts/drafts/** as a second argument excludes the files in posts/drafts/ from scanning/output.

walkcontent -d content 'posts/drafts/**'
{
  "content/blog/2024-02-01/index.md": {
    "$contentStart": 4,
    "$date": "2024-02-01",
    "$h1": "Second Post",
    "$mtime": 1706745600,
    "author": "Jane Doe"
  },
  "content/posts/2024-01-15-hello-world.md": {
    "$contentStart": 4,
    "$date": "2024-01-15",
    "$h1": "Hello World",
    "$mtime": 1705320000,
    "tags": ["intro"],
    "title": "Hello World"
  }
}

Above, $date is picked up from a directory name too (2024-02-01), and $mtime reflects each file's actual modification time. $h1 is the top-level heading in the file, and the rest of the data is frontmatter. $contentStart is the line number where content after the frontmatter block begins (1 if the file has no frontmatter).

Install

go install github.com/sidvishnoi/walkcontent@latest

Or, via npm (installs a prebuilt binary, no Go toolchain required):

npm install -g walkcontent

Usage

Basic

$ walkcontent -d content

Output is written to stdout by default.

{
  "content/posts/2024-01-15-hello.md": {
    "$contentStart": 4,
    "$date": "2024-01-15",
    "$h1": "Hello",
    "$mtime": 1705320000,
    "title": "Hello"
  }
}

Multiple directories

You can pass multiple directories to walkcontent to scan them all.

walkcontent -d notes -d articles

Ignore patterns

You can pass ignore patterns that walkcontent matches via doublestar globs. Pass the patterns in single quotes instead of relying on shell expansion.

walkcontent -d content 'drafts/**' '*.tmp.md' -d blog 'unpublished/**' -o output.json
# For the `./content` directory (-d), exclude files matching patterns `drafts/**` and `*.tmp.md`;
#  and for the `./blog` directory, exclude `unpublished/**` pattern files.
# The output is written to `output.json`

Include content

Pass --include-content to also collect every heading and link found in each file's content (in document order), as $headings and $links. This requires parsing the whole file (with goldmark), so it's slower than the default.

Each heading/link's text has markdown formatting stripped (e.g. **bold** becomes bold); rawText holds the original markdown and is only included when it differs from text.

walkcontent -d content --include-content
{
  "content/posts/2024-01-15-hello.md": {
    "$contentStart": 4,
    "$h1": "Hello",
    "$headings": [
      { "level": 1, "text": "Hello" },
      { "level": 2, "text": "Section", "rawText": "**Section**" }
    ],
    "$links": [{ "text": "my other post", "href": "/posts/other" }],
    "$mtime": 1705320000,
    "title": "Hello"
  }
}

Help

walkcontent -h

Notes

  • I built this project to learn Go.
  • I use this tool with my Astro blog (sidvishnoi.com):
    • I write relative file paths as links in Markdown, and an Astro plugin maps them to computed post URLs at build time. This ensures my markdown content is independent of my site's URL structure.
    • I also plan to use this to build a sitemap for my blog. Astro's sitemap plugin is great, but I think I can create a more custom better-structured sitemap using this tool.