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

swanny

v0.0.4

Published

A static site generator that's easy to understand.

Downloads

11

Readme

swanny

A static site generator that's easy to understand.

Developing a site

swanny transforms a directory of files into a directory of static files.

It transforms content by running each file through one of your extensions (depending on the extension in the filename) then optionally passes the result through one of your layouts to generate the final static output.

At development time swanny automatically applies changes to your web pages using livereload.js.

For example:

GET http://example.com/some/page

...corresponds to:

content/some/page.md

...which is rendered with:

extensions/md.js

..finally generating within a layout defined at:

layouts/default.js

Running the swanny server

You could install swanny globally:

npm i swanny -g

...and then run the server:

swanny server

...or publish the static files:

swanny publish

Adding swanny to your project

Usually you should swanny it to your project:

npm init
npm i swanny --save

Then register swanny as the start script in your package.json file:

  "scripts": {
    "start": "swanny server",
    "publish": "swanny publish"
  }

Now npm start will start the swanny server. You can leave it running, it'll transform your content and refresh the static site when it notices changes to your contents.

When you are ready to deploy then npm run publish will create a public directory with your static files

Content

Content files live in your project's content directory. The extension of any file in this directory should correspond to the name of a node module in your extensions directory. This extension will be removed when the static file is generated.

Extensions

An extension module transforms a file with that extension into an object, which can be either:

  • Some content and a nominated layout for post-processing:
module.exports = path => ({
  layout: 'admin',
  content: 'Welcome to the dashboard'
})
  • or a response object with a content type and body:
module.exports = path => ({
  contentType: 'text/css',
  body: '* { color: red }'
})

Layouts

A layout takes the result of calling the extension on the file, and transforms that into a response object:

module.exports = content => {
  return {
    contentType: 'text/html',
    body: '<html><body>' + content + '</body></html>'
  }
}