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

spg

v0.1.0

Published

Static Page Generator

Downloads

6

Readme

Spg - Static Page Generator

Simple generator static pages. To generate use swig templates and markdown files to create content. Spg allows you to define multiple pages and a series from specified directory. Only what you need is other web server (like apache or nginx), define templates in swig and configuration ini file.

Install

npm install -g spg

Tutorial

You must create dirs, config file, md files with content and templates.

mkdir my-test-page
cd my-test-page
mkdir articles
mkdir public
mkdir view
touch config.ini

Edit config.ini and define pages:

[_global]
config.destonationPath = public/ ; path wher new file was create
config.fileName = index.html ; file name

[index : _global] ; inherits the settings from the section _global
config.templateFile = view/index.html ; template file for site "index"
config.fileName = index.html ; file name
; define for series pages
articles.sourcePath = articles/ ; path where searh md files
articles.order = path ; order files by
articles.destonationPath = public/articles/ ; destonation generated files
articles.ext = html ; change md extension for html
articles.templateFile = view/article.html ; template file

[history : index] ; inherits the settings from the section index
config.templateFile = view/history.html ; change template name
config.fileName = history.html ; change destonation file name

[about : _global]
config.templateFile = view/about.html
config.fileName = about.html

Create templates in view dir How to create templates files If you want use article's list in template, you must write something like this:

{% for art in articles %}
<div>
    {{ art.introText|raw }}
</div>
<div>
    <ul class="nav nav-pills">
        <li><a href="/articles/{{ art.destRelPath }}" title="{{ art.firstLine|title }}">Czytaj więcej</a></li>
        <li><a href="/articles/{{ art.destRelPath }}#disqus_thread" title="{{ art.firstLine|title }}">Komentuj</a></li>
    </ul>
</div>
{% endfor %}

Article atributes:

art = {
    fullText: /* html file generated from md */
    introText: /* html file generated from md to tag <!-- more --> */
    firstLine: /* first line from md */
    sourcePath: /* path to md file */
    sourceRelPath: /* relative path to file */,
    destPath: /* destonation path to html file */
    destRelPath: /* relative path to html file (can be use to create links) */
    size: /* size md file */
    atime: /* data from fs.statSync */
    mtime: /* data from fs.statSync */
    ctime: /* data from fs.statSync */
}

In view/article.html template use variable data

{% block content %}
    {{ data.fullText|raw }}
{% endblock %}

Ok you have config and templates. Create yours .md pages in articles/ dir and run commend:

spg --config=config.ini

In "public" should appear html files.

Configure your webserwer and is done.

Help

Create a issue if something is not clear.