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

static-mina

v0.1.8

Published

Stamina is a frontend nanoframework and static site generator.

Downloads

5

Readme

sta-mina

npm version Build Status

Minimal static/dynamic site generator. status: in development, YouTube demo

preview

Sample snapshot of a render of the git-project template.

Background

Stamina uses templates that are parsed as template literals. It is a minimal static site generator and web framework in one. With two modes of site generation.

Installing

Installing the generator is super easy.

λ npm install -g static-mina

'stamina' should now be available on your CLI, check it with

λ stamina -h
usage: console.js [-h] [-v] [-f FILE] [-d] [--template TEMPLATE] [--data DATA]
                  [--configure]

Sta-mina static site generator.

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -f FILE, --file FILE  local file with project settings.
  -d, --dynamic         generate a dynamic site, default is false.
  --template TEMPLATE   local file or URL to a .html template.
  --data DATA           local file or URL to a .json file.
  --configure           generates project configuration.

Ready to rock!

Tutorial

Example of a minimal template

<html>
<style>
	span {
		color: ${theme.font}
	}
</style>
<body bgcolor="${theme.bg}">
	<span>${text.title}</span>
</body>
</html>

A sample data file used to render the template,

{
  "theme": {
    "font": "red",
    "bg": "#000"
  },
  "text": {
    "title": "hello world."
  }
}

Now, create two files template.html to hold the template data and site.json to hold the data.

When installed we can generate a static site using the following snippet,

λ stamina --template template.html --data site.json

Alternatively, we can create a dynamically loaded site using this,

λ stamina --dynamic --template template.html --data site.json

Dynamic sites are rendered at runtime, which means that we can point to two templates at arbitrary locations - maybe you want your site.json to be available in your git repo for example.

After running the above commands the generated site will be present under build/site/*.

Multi-project setup

To create a new project configuration file run the following,

λ stamina --configure

This creates the file stamina.json in your current directory.

{
  "sites": [{
    "template": "path/to/your/template.html",
    "data": "path/to/your/data.json",
    "dynamic": false,
    "name": "sample-site",
    "web": "./web"
  }]
}

Sites is a list of sites you want to build, a template and data file needs to be specified. Name is optional and defaults to the filename of the data file. Dynamic indicates if we are to generate a dynamic or static site. Web is an optional directory with static resources to copy to the output directory, place your css/js/images there.

Building a multi-project setup

Build all projects in stamina.json

λ stamina

Build all projects in configuration file settings.json,

λ stamina -f projects/settings.json

Build with specified project file and site name,

λ stamina -f projects/settings.json --name mywebsite-1

Linking in multi-site projects

The only real feature apart from site generation is linking. Links are resolved at compile time and are used to create multi-site projects.

A link can be created using the framework by invoking the following method, link(template, data, content).

template - a local template file or in the future also a remote file. data - a local data file or in the future also a remote file content - this is the content of the link that is created.

Example

<div class="some-css">
	${link('templates/git-project.html', 'sites/my-project.json', 
		`<div>click me</div>`
	)}
<div>

Produces the following link in static mode:

<a href="javscript:void(0)" onmousedown="event.which == 1 ? location.href='template' : ''">
	content
</a>

Note that 'template' here will reference a new filename, which is the template rendered with the referenced json file.

A link looks like this in dynamic mode:

<a href="javscript:void(0)" onmousedown="link_load(template, site)" onmouseover="link_preload(template, site)">
	content
</a>

When the link is hovered the loader issues two network requests to fetch the template and jso file. When a link is clicked in dynamic mode, the template is rendered and a new document is written without navigating to a new site.

For sites that don't require multiple templates, we recommend using regular links.

History

History works fine for static pages, when using the link feature in dynamic mode no support is implemted yet. Altough it is planned and is easily implemented in the loader :)

Contributing

All contributions are welcome, new issues, pull requests and ideas!

donate