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 🙏

© 2024 – Pkg Stats / Ryan Hefner

blad

v4.0.2

Published

A minimalist flat-file CMS with dynamic content

Downloads

38

Readme

blað

A minimalist flat-file CMS with dynamic content.

Build Status Dependencies License

Features

  1. Reads content from Markdown files and YAML front-matter.
  2. No database or write access to disk needed.
  3. In-memory cache maintains dynamic content defined in helper functions.
  4. Powerful Swig templating.

Quickstart

$ npm install blad -g
$ blad --port 8080
# blad/4.0.0-alpha started on port 8080

Configuration

The following command will launch a blad server on port 5050, sourcing files from the example/ directory and keep all cached content for a period of 1 day.

$ ./bin/blad.js --port 5050 --source example/ --cache 1440

Content

The site pages are maintained as sets of Markdown files with YAML front-matter. The name corresponds to the url of the page so, for example, /content/people/radek.md will get mapped to the /people/radek URL.

Among the fields one can set in the front-matter, template is the most important one. It sets a Swig HTML file that will be used to render the page. Not specifying this property will make the page serve 204 No Content when accessed.

Fields are represented as key-value pairs of arbitrary depth.

Layouts

Is a place where Swig templates live. They can be extended and macros work too.

If a 404.html template is provided together with a document entitled 404.md, these will be rendered when a user tries to visit a page that does not exist.

You can access the URL of a page you are on by using the url key.

Relations

You can access content in other documents by using the relations helper object.

To get a list of top-level pages in the CMS use:

{% for page in rel.menu() %}
  {{ page.url }}
{% endfor %}

To get a list of sibling documents:

{% for page in rel.siblings(url) %}
  {{ page.url }}
{% endfor %}

You can get a list of children of depth n:

{% for page in rel.children(url, n) %}
  {{ page.url }}
{% endfor %}

Access the first existing parent document:

{% set parent = rel.parent(url) %}

Check if one document is the same as another or one of its descendants:

{% set isFamily = rel.isFamily('/people', '/people') %}

Or just check if one document is a child of another:

{% set isChild = rel.isChild('/people', '/people/radek') %}

Helpers

Are modules (in JS or CoffeeScript) that can be accessed at page render stage. Typically they will be used to access remote data to then be rendered in a page. In a YAML front-matter we would request a helper like so:

---
helpers:
  people: my_helper.js
---

The first time a page is rendered, the helper in my_helper.js is called. It is expected to be a function with two parameters, data and cb. The former is a map of key-value fields from the front-matter, the latter a callback for when the helper has done its job. As an example:

module.exports = (data, cb) => {
  // Do some work...

  // Call back.
  cb(null, result);
};

You can access 3rd party libraries here by defining them in package.json of the site.

The data is then accessible under the key people (in the example above) in the page layout and saved for --cache amount of time. This is a startup parameter and saves having us make potentially expensive operations every time a page is requested.

Public

All static content, like CSS and JS files, can be accessed here. Use /public/path in layouts when accessing these files.