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

plain-static

v1.5.1

Published

A simple static site generator.

Downloads

20

Readme

Plain Static

A simple static site generator. For those times that you don't need streams or pipes or plugins... you just need a site built quickly.

Currently only works with Markdown, Mustache, and Less.

Install

npm install plain-static --save-dev

Use

// Options
var opts = {};
// Require and init
var plainStatic = require('plain-static')(opts);

// Build all the things!
plainStatic();

Options

  • opts.src Build source path. Default is src.
  • opts.targetFiles Focused file pattern. Default is /**. Used to filter what files to process/copy/watch.
  • opts.dest Build destination path. Default is dist.
  • opts.appRoot Root path. Default is the current working directory.

Templates

A JSON file is parsed and stored in the main data object. The data is mostly left untouched except when it discovers a markdown property. Every parsed object is stored in the main object using the file name.

Markdown property

The markdown property should be a file name that can be found in the defined source directory. You'll get a nasty error during build if it's not there!

So, if the object looks like:

{
  "title": "hello!",
  "markdown": "index.md"
}

The parsed object will look like...

{
  title: "hello!",
  content: 'MARKDOWN PARSED INTO HTML'
}

The Markdown file is processed using the data object. The markdown property is stripped from the object. The tool will also do a deep check for nested markdown properties.

Data Objects

Although JSON is the default (and simpler) data object to use, PlainStatic also supports creating a data object programmatically in a JavaScript file. Just return the desired plain JavaScript object using the module exports directive and PlainStatic will do the rest.

Mustache Helpers

In order to create Mustache helpers, you need to create your data object in a JavaScript file. Consider the following file:

var moment = require('moment');

module.exports = {
  markdown: 'index.md',
  footer: {
    markdown: 'footer.md'
  },
  formatDate: function () {
    return moment(this._meta.today).format('YYYY');
  }
};

In this file, named index.js, the Mustache helper formatDate will be available only to files named index. For example, index.md will have access to this file but not about.md. This makes it easier for PlainStatic to associate related files. See Data Storage and File Structure below for more info.

Global Data

Reusing the same data in multiple JSON/JS data files is not helpful. Be creating a file named global.json or global.js, PlainStatic will parse the data and place it the namespace _global within the data object. All templates have access to this object and can use simply by accessing the property. For example: {{_global.title}}.

This is very useful for navigation items, page titles, or common Mustache helpers.

Data storage and File Structure

If the source directory looks like this:

  • src
  • index.json
  • about.json
  • index.mustache

The resulting data object would look like:

data: {
  index: {},
  about: {}
}

Although, when the tool attempts to build the templates, it will never use the about property since there is no about template.

Contact

Juan Orozco

License