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

@stageny/base

v2.0.9

Published

Simplistic static site generator

Downloads

234

Readme

Introduction

Stageny (without plugins) is a basic but powerful static site generator that focuses on performance, versatility and simplicity. It has been born out of the wish for a (node/js only) replacement for Middleman.

It compiles pages written in many templates languages (but prefering PUG) into HTML. It does not compile to CSS or JS or anything else.

A page is built with those 4 elements

Pages

A page has two parts: frontmatter data and the actual template. (JS is slightly special, see below).

The frontmatter will be parsed right away so you can use it for routing / sitemap. It will be accessible in templates via _meta. Put into data what you want to populate to the merged data object.

i-am-a-page.html.pug

---
title: I am a page
data:
  date*: new Date()
layout: default
---

h1 #{_meta.title} from #{date.toLocaleString()}
p With not much content

or i-am-a-page.html.js

module.exports = {
    data: {
   	 title: 'I am a page',
   	 layout: 'default',
   	 data: {
   	 	date: () => new Date()
   	 }
    },
    render(data) {
   	 return `
   		<h1>${data._meta.title} from ${data.date}</h1>
   		<p>With not much content</p>
   	`
    }
}

Stageny in its core supports Components and Layouts.

Layouts

A page's frontmatter layout: default points to a specific layout:

layouts/default.pug:

html
	head
		title #{_meta.title}
	body
		!= content

A layout too can have frontmatter which will be overruled by the page (except for layout which you use to define a super layout).

Components

Components must be uniquely named, no matter their file path. Frontmatter serves as default paramters.

components/Button.pug:

---
tag: button
content: Button
---

#{tag}.Button(type=(tag === 'button' && tag))!= content

content is a special parameter, at least in pug, as the slot will be put into it.

page.html.pug:

+Component('Button')
	i.Icon(data-icon="plus")
	| Add

page.html.js:

module.exports = function(data) {
	return data.component('Button', {
		content: `<i class="Icon" data-icon="plus"></i> Add`
	})
}

Data

Data can be global or on a page level.

Data will be applied in this order:

  • _page and internal component helper
  • data and _data (if Data Plugin)
  • helpers and _helpers (if Helper Plugin)
  • page frontmatter (also via _page.meta)

Page

  • url
  • meta
  • content
  • result
  • render
  • rawMeta

Events / Plugins

Plugins (and helpers) can sneak into any of those events:

  • init (before first run)
  • on every run:
    • start
    • sitemap (array of pages)
    • for every page:
      • beforepageprocess (file)
      • beforepagedata (file, data)
      • afterpagedata (file, data)
      • beforepagerender (file)
      • afterpagerender (file)
      • afterpagewrite (file)
      • pageerror (file)
    • end