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

blego

v1.0.0

Published

Static site generator powered by colections and relationships.

Readme

Blego

Blego is an exceptionally powerful and easy to use static site generator. It's a great choice for beginners AND veterans.

Progressively dynamic templates

Blego makes developing purpose-built templates effortless but it also enables a progressive transformation of static HTML sites. This makes Blego the perfect companion for thousands of existing HTML templates.

Relational data model

Blego is powered by an unopinionated data model that supports multiple types of relationships. It is trivial to access related data across multiple levels of hierarchy.

Flexibility

Blego is flexible enough to generate any type of a website like Blogs, Stores or Wikis. In fact, it can handle a lot more than just websites. It can generate XMLs, PDFs or even images.

Using Blego

Requirements

Blego requires Node.js 18 or newer. Visit https://nodejs.org to learn more.

Creating a project

npx blego new my-project

This will create a new directory with a simple Blego project already set up. You can replace my-project with any directory name you like.

Building a project

npx blego build

This will build your project and save it to the dist directory.

Serving a project

npx serve

This will start a web server from the dist directory. Visit http://localhost:3000 to see your generated project.

File system

Standard Blego project is preconfigured with the following files and directories.

data: Contains data files parsed into Stores. Learn more.

globals: Contains data files available globally. Learn more.

static: Contains files copied directly to the dist directory. [Learn more](#Static files).

template: Contains Handlebars.js template files. Learn more

blego.js: This is the brain of your Blego project. This file contains definitions of all relationships and instructions on how to build your project.

Building pages

To build a page add the following code to the blego.js file.

blego.page('page.html', 'welcome.html', { title: 'Hello World' });

This will create page.html using the welcome.html template populated with data passed in the last argument.

Template

Template files use Handlebars.js to fill in static markup with dynamic content.

<div class="entry">
  <h1>{{ title }}</h1>
  <div class="body">
    {{ body }}
  </div>
</div>

All templates are treated as Handlebars.js partials. This means that you can compose templates using shared components.

{{> header.html }}
Hello World
{{> footer.html }}

There is a lot more that Handlebars.js can do. Visit https://handlebarsjs.com to learn more.

Macros

Macros allow you to call Javascript functions from your template.

For example, you may want to report when the page was generated.

First you need to register a macro in the blego.js file.

blego.macro('currentDateTime', () => new Date().toLocaleString());

You can then use it in your templates.

<span>{{ currentDateTime }}</span>

Macros can also accept arguments.

blego.macro('getUserAge', (user) => user.age || 'Age not available');
<span>{{ getUserAge user }}</span>

Macros use Handlebars.js helpers. Visit https://handlebarsjs.com/#helpers to learn more.

Static files

Not all files used by a website are dynamically generated. Put your static files like images, CSS, etc. in the static directory and Blego will automatically copy them to the dist directory when building.

Data

Blego creates data Stores by parsing files from the data directory.

First tier subdirectories represent the Store name while the remaining file path represents the Record key. File extension is omitted from the Record key.

.
+- Data
   +- Pages
      +- home.md
      +- about.md
      +- about
         +- contact.md

Given this file structure, Blego will create a Store called Pages with 3 Records. The Records will have the following keys.

- home
- about
- about/contact

Stores

Stores provide many ways of accessing and manipulating the Records.

For example, you may want to get twitter handles for the five newest users.

blego.data.Users.sortBy('joinedAt').reverse().take(5).pluck('twitter');

See the API reference to learn more.

Data file types

Blego can parse many different data file types.

  • Markdown files use .md file extension.
  • HTML files use .html file extension.
  • Javascript files use .js file extension.
  • JSON files use .json file extension.
  • YAML files use .yaml file extension.

Markdown and HTML data files support Front Matter. Meta data provided is exposed as parameters of the Record while the content is available via the body parameter.

Visit https://github.com/jxson/front-matter to learn more about Front Matter.

Javascript data files must export an object which will be merged into the Record.

JSON and YAML files are parsed into Javascript object and merged into the Record.

Globals

Some data may need to be available globally. Data files in the globals directory will be automatically made available in every template file.

Note: Global data is a Javascript object and not a Store.

Below is a simple config.json file placed in the globals directory.

{
  "site_name": "My Project"
}

The data can be accessed in any template.

<h1>{{ config.site_name }}</h1>

Relationships

Blego must be told how the data models relate to each other. You may be used to thinking about relationships as one-to-one or one-to-many. However, it is important to also understand the direction of the relationship.

For example; A team has many players but a player has one team.

When creating a relationship between Books and Authors it makes a lot more sense to define the Authors in the Book model. But, this relationship must work both ways.

To define bidirectional relationship between Books and Authors you need to add the following code to the blego.js file.

blego.data.Books.linkToMany(blego.data.Authors, 'authors');
blego.data.Authors.linkFromMany(blego.data.Books, 'authors', 'books');

This will replace the Author keys in authors property of Book Records with actual Author Records. And, add books property to the Author Records containing related Book Records.

See the API reference to learn more.