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

@hjoncour/simpleblog

v0.5.0

Published

Portable collection logic and a React rich-content renderer for blogs and project showcases.

Readme

simpleblog

simpleblog is a small ESM-first library for sites that keep their content in local JSON but want reusable collection logic and a portable React renderer for rich content blocks.

It is designed for setups like:

  • content stays inside the app repo
  • JSON remains simple and ad hoc
  • routing and page shells stay app-specific
  • query logic and rich-content rendering move into a shared package

Install

npm install simpleblog

The core package works without React. simpleblog/react expects react >= 18.

Core Usage

import {createCollection} from 'simpleblog';

const posts = createCollection({
  name: 'posts',
  identity: 'slug',
  load: async (locale: string) => {
    const module = await import(`./content/${locale}/posts.json`);
    return module.default;
  },
  defaultSort: {by: 'date', direction: 'desc'},
  recentSort: {by: 'date', direction: 'desc'},
  searchFields: ['title', 'preview', 'tags', 'content'],
  defaultTagMode: 'or',
});

const allPosts = await posts.list({locale: 'en'});
const recentPosts = await posts.recent({locale: 'en', limit: 4});
const currentPost = await posts.get('hello-world', {locale: 'en'});

React Renderer

Built-in blocks can stay ad hoc:

[
  {"h2": "Hello"},
  {"p": "Lorem ipsum dolor sit amet.\n[Read more](https://example.com)"},
  {"ul": ["First item", "Second item with a [link](https://example.com)"]},
  {"img": "https://picsum.photos/1200/600"}
]

video takes a URL, or an object with playback options:

[
  {"video": "https://res.cloudinary.com/demo/video/upload/f_auto,q_auto/clip.mp4"},
  {
    "video": {
      "src": "https://res.cloudinary.com/demo/video/upload/f_auto,q_auto/clip.mp4",
      "poster": "https://res.cloudinary.com/demo/video/upload/so_0/clip.jpg",
      "autoplay": true,
      "loop": true
    }
  }
]

controls defaults to true unless autoplay is set, muted defaults to the value of autoplay (browsers block unmuted autoplay), playsInline defaults to true, and preload defaults to "metadata". src and poster both go through resolveAsset.

ul and ol take an array of items. Items are strings, or objects with text plus optional className / style:

[
  {
    "ol": [
      "Plain item",
      {"text": "Highlighted item", "style": {"fontWeight": 700}}
    ]
  }
]

table takes an array of rows for a plain grid, or an object when it needs headers, a caption, a footer, or styling:

[
  {"table": [["Lorem", "Ipsum"], ["Dolor", "Sit"]]},
  {
    "table": {
      "caption": "Lorem ipsum per column",
      "headers": ["Name", "Count", "Notes"],
      "align": ["left", "right"],
      "rows": [
        ["Lorem", 12, "Plain row with a [link](https://example.com)"],
        {
          "cells": [{"text": "Ipsum", "header": true}, {"text": "Spans two columns", "colSpan": 2, "style": {"fontStyle": "italic"}}],
          "className": "highlighted-row"
        }
      ],
      "footer": ["Total", 12, ""],
      "className": "my-table",
      "style": {"fontSize": "0.875rem"},
      "presentation": {
        "th": {"style": {"textTransform": "uppercase"}},
        "td": {"className": "my-cell"}
      }
    }
  }
]
  • headers and footer are a single row; rows is an array of rows. A row is an array of cells, or {"cells": [...]} with optional className / style.
  • A cell is a string, a number, or an object with text plus optional align, colSpan, rowSpan, header (renders a row header <th>), className and style. Cell text supports the same links and inline HTML as p.
  • align sets left / center / right per column; a cell's own align wins.
  • className / style on the table object apply to the <table> element. presentation restyles the parts of that one table: wrapper, table, caption, thead, tbody, tfoot, tr, th, td.
  • sortable: true turns the header cells into buttons that sort the body rows: ascending, descending, then back to the declared order. Values that look like numbers sort numerically, a cell's sortValue overrides the text used for sorting, and empty cells stay last. sort sets the initial order, e.g. {"column": 1, "direction": "desc"}. It needs a headers row and client-side React, and it is not meant for tables that use rowSpan. The buttons are styled through the sortButton and sortIndicator parts.
  • id overrides the generated element id of the <table>; its parts derive their ids from it.

The same part names are available app-wide through the theme:

const theme: RichContentTheme = {
  table: {
    wrapper: {className: 'my-4 overflow-x-auto'},
    th:      {className: 'px-3 py-2 text-left font-semibold'},
    td:      {className: 'px-3 py-2'},
  },
};

The table sits in a horizontally scrollable wrapper so wide tables do not overflow the page on small screens.

Custom components use an explicit shape:

[
  {
    "component": "demoCallout",
    "props": {
      "title": "Lorem ipsum",
      "body": "Dolor sit amet"
    },
    "presentation": {
      "className": "my-callout",
      "style": {
        "marginTop": "1.5rem"
      }
    }
  }
]
import {RichContentRenderer, createComponentRegistry} from 'simpleblog/react';

const components = createComponentRegistry({
  demoCallout: DemoCallout,
});

<RichContentRenderer content={post.content} components={components} />;

Styling

Styling merges in this order:

  1. library defaults
  2. app-level theme overrides
  3. per-block presentation for custom components or className / style for ad hoc built-ins

The renderer supports both className and inline style.

For tables the order is: library defaults, theme.table, the table's own presentation, column align, then the row's or cell's className / style.

Element ids

Every element the renderer outputs has a deterministic id built from the block's position: simpleblog-root, simpleblog-block-3, simpleblog-block-3-h2, simpleblog-block-3-ul-item-0, simpleblog-block-3-table-row-1-cell-0, and so on. Pass idPrefix to replace the simpleblog prefix, which is required to keep ids unique when more than one RichContentRenderer is on the same page.

HTML Safety

HTML is sanitized by default. Trusted HTML is available via htmlMode="trusted" when the content source is fully trusted.

Examples

Example JSON lives in examples/posts.en.json and examples/projects.en.json.