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

ship-ssg

v1.1.3

Published

Static HTML Interpolated Partials, a minimal way to generate static sites.

Downloads

10

Readme

Ship (Simple HTML Interpolated Partials)

Summary

Ship is a minimal static site generator to be used as a CLI tool. All it does is interpolate partials and spit out the end result.

It can take in any utf8 text file format (mostly intended for HTML though), and has only one syntax to remember:

{{ partial "relative/or/absolute/path/to/partial/file" }}

This will grab the content of that file and replace that syntax in the output wherever it's found.

Install

npm install -g ship-ssg

Run

npx ship-ssg path/to/project/root --output path/to/output/folder --watch

Defaults to src and dist in current working directory for input and output folders if you just run npx ship-ssg or npx ship-ssg --watch

Nested Partials

It works with nested partials, so if you have a partial that has a partial, that has a partial, etc., it should just work.

If you add partials in a circular manner, it should warn you and stop at max 10k recursions. You'll need to remove that circular partial dependency to continue.

Example of circular partials: file 1 contains partial 2, which calls file 1 as a partial, causing an infinite loop.

Flags/Params

By default it assumes your input folder is src in your current working directory, and that your output folder is dist.

You can change that:

  • Set input folder using npx ship path/to/input/folder
  • Set output folder using npx ship --output path/to/output/folder
  • Set it to watch for any changes in your input folder using ship --watch
  • Combine them all like this npx ship path/to/input/folder --output path/to/output/folder --watch

Folder Structure

Inside of your input folder (defaults to src in your current working directory), there is only one special folder: _partials

Anything in _partials will not be directly output to the output folder. It's a way of excluding files that are only to be used as partials for other files.

What is a partial?

Any utf8 file you want anywhere in your project folder. Use at your own discretion, you know what you're doing.

Examples of ways you can use partials:

  • index.html calls _partials/header.html -> outputs an index.html to dist with the header interpolated
  • index.html calls /_partials/some_folder/some_partial.html -> outputs an index.html with that file interpolated
  • index.html calls about.html -> outputs an index.html with the entire about page interpolated, and also outputs the about.html page to dist

Assets and other files

Any file that is not text (e.g. binaries like images, media, PDFs, etc) will just be copied as they are to the output folder.

Using with other CLI tools

If you want to use this with other CLI tools, like say tailwind, you probably just want to run them on changes to the output folder.

Example: npx ship --output some/output/folder & npx tailwindcss -i ./some/output/folder/input.css -o ./some/output/folder/output.css --watch

Or you could just run them in different terminals. However you want to run multiple long running CLI processes.

Why don't you have X? You should really add X.

Ship hears you. Ship don't care.

The idea here is simplicity rather than a sophisticated CMS. There's plenty of those out there already with Hugo, Astro, etc.

I mean, unless your idea is really good. Never say never.