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

pagez

v1.4.3

Published

A library to manage static HTTP pages

Downloads

3

Readme

Pagez CI

Allows to declare pages and add a bit of post-processing to them.

Usage

(pages.np)

(pages) { %%!auto
    root = "/"

    [/] { @"index.html" }
    [script.js] { @"script.js" }
    [style.css] { @"style.css" }
}

(index.js)

const { Pages, builtinLib } = require('pagez');

const pages = new Pages()
    .addFile('pages.np')
    .use(builtinLib)
    .build({
        defaultSource: 'public',
        outputPath: 'dist'
    })
;

The above example would parse the pages file, store and minify the HTML and JS files from source in a dedicated dist folder.

We can also plug it into an HTTP server, which would look like this:

(index.js)

const { Pages, builtinLib } = require('pagez');
const http = require('node:http');

const pages = new Pages()
    .addFile('pages.np')
    .use(builtinLib)
    .build({
        defaultSource: 'public',
        outputPath: 'dist'
    })
;

const server = http.createServer(
    ( req, res ) => {
        const url = new URL(req.url, `http://${req.headers.host}`);
        const page = pages.getPage(url.pathname);
        if (page) {
            res.statusCode = 200;
            for (const [k,v] of Object.entries(page.page.props.__headers||{}))
                res.setHeader(k,v);
            res.end(page.body);
        } else {
            req.statusCode = 404;
            res.end();
        }
    }
);

server.listen(8080,'localhost',()=>console.log('Ready!'));

Pagez Language (Nogis Pagez)

A namespace is denoted by parenthesis, and its body by curly braces:

(pages) {

}

Inside it may be properties, like the root path of the namespace:

(pages) {
    root = "/"
}

As well as pages, with their name denoted by square braces and their body by curly braces:

(pages) {
    root = "/"

    [/] {

    }
}

To indicate the path of the resource, we can use the @ symbol followed by the path between quotes:

(pages) {
    root = "/"

    [/] {
        @"index.html"
    }
}

But we might want to minimize it, and for this we can tag it with min:

(pages) {
    root = "/"

    %min
    [/] {
        @"index.html"
    }
}

While we're there, we could also want to tell the client what kind of ressource it is (not particularily useful here, but it might be in other cases):

(pages) {
    root = "/"

    %min
    %kind<"text/html">
    [/] {
        @"index.html"
    }
}

But, using only kind without giving it an argument will auto-detect which one it is based on the path's extension. Moreover, we can use the auto macro that does all of that:

(pages) {
    root = "/"

    %!auto
    [/] {
        @"index.html"
    }
}

But if there is a feature we wouldn't like to be applied we can use a dash to cancel it:

(pages) {
    root = "/"

    %!auto
    %-min
    [/] {
        @"index.html"
    }
}

And if we have multiple pages, we can place them in curly braces and put the decorators on top:

(pages) {
    root = "/"

    %!auto
    {
        [/] { @"index.html" }
        [script.js] { @"script.js" }
        [style.css] { @"style.css" }
    }
}

As we are applying auto to all of the pages, we can move it to the very top and add another `%` to signify it is global:

(pages) { %%!auto
    root = "/"

    [/] { @"index.html" }
    [script.js] { @"script.js" }
    [style.css] { @"style.css" }
}