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

sold

v3.0.0

Published

minimal static site generator

Downloads

43

Readme

Sold

A minimal static blog generator.

Getting Started

Run this to install Sold

$ npm install sold -g

Usage

  1. Create instance of Sold in sold.config.js
const Sold = require("sold");

Sold({
	root: __dirname, // root folder (default is current working directory)
	template: "template", // template folder relative to root (default is "template")
	source: "src", // source folder relative to root (default is "src")
	destination: "dist", // destination folder relative to root (default is "dist")
	feed: {}, // feed options (default is `{}`)
	marked: {} // marked options (default is `{}`)
});
  1. Create or download a template and put it in the template directory.

  2. Create a folder called src (or whatever you named the source).

  3. To make a new post, make a markdown file, for example post.md in the source folder. Put some metadata at the top to let Sold know of the title and description of the post, then put your content. For example:

---
title: First Post
description: My very first post
---

Hey! This blog post was made with [Sold](https://github.com/kbrsh/sold).
  1. Run
$ sold
  1. Check out the generated files in the dist directory.

Templates

A template should be in the file declared in the template option of an instance. Sold will, by default, search in the template directory. They support EJS syntax.

index.html

This file should contain the home page. It will be provided the following:

{
	options: {}, // options provided to `Sold`
	posts: [] // list of posts
}

post.html

This file should contain the template used for each post. All contents of the metadata provided at the top of each post's markdown content is provided in a template here, and the HTML for the post is provided in content. The HTML code should be unescaped. It will be provided the following:

{
	options: {}, // options provided to `Sold`
	post: {
		file: "", // base name of file (without extensions)
		content: "", // HTML content of compiled markdown
		...meta // metadata in front-matter of markdown file
	},
	posts: [] // list of all posts
}

If an order option is defined in the metadata, then the posts will be given in ascending order using the value. If there is a date option and no order, the posts will be ordered in descending order using the date (most recent first).

For example:

<h1><%= post.title %></h1>
<h3><%= post.description %></h3>
<p><%= post.file %></p>

<% posts.forEach(post => { %>
	<%= post.title %>
<% }); %>

<%- post.content %>

JSON Feed

If you want to generate a JSON Feed for your blog-like site, add this to your configuration:

Sold({
	feed: {
		JSON: {
			title: "My Awesome Blog", // the title shown in the feed
			home_page_url: "https://my.awesome.blog" // the HTTP(S) URL to where the site will reside
		}
	}
});

A post can look like this:

---
title: First Post
date: 2019-08-01 12:00 PST
description: My very first post
author:
   name: John Doe
   url: https://example.com
tags:
   - first
   - sold
---

Hey! This blog post was made with [Sold](https://github.com/kbrsh/sold).

Posts that have draft: true won't appear in the feed, and the feed will only contain only so many recent posts so that it doesn't exceed 256 KiB. Optional fields supported by the post include title, summary, image, author, date, and tags.

Note that the date metadata entry must be valid input to Date.parse. Posts are ordered by the order property if it is present, or else they are sorted by date. If neither are present, then they are not sorted at all.

The feed will be generated at /feed.json; you can add that to your index template, preferrably in the header like this:

<link rel="alternate" type="application/json" title="JSON Feed" href="/feed.json"/>

License

Licensed under the MIT License by Kabir Shah