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

node-amp-mustache-skeleton

v1.3.1

Published

AMP page skeleton served via node.js featuring mustache templating.

Downloads

2

Readme

node-amp-mustache-skeleton

AMP page skeleton served via node.js featuring mustache templating and equipped for Dockerization.

Quick start

  • Fork this repo.
  • npm i -g gulp-cli
  • npm i
  • npm start
  • Navigate to http://localhost:8080 in your browser to see stuff.
  • Start developing.

Intro

Directory layout

  dist/                                 # production code
    pageA/
      index.html
    pageB/
      index.html
    img/
    google-site-verification.html
    index.html
    index.js
    package.json
    package-lock.json
    robots.txt
    sitemap.xml
  src/                                  # source code
    img/                                # images
    json/                               # json data
    seo/                                # seo related files
      robots.txt
      google-site-verification.html
      sitemap.xml
    server/                             # node server source
      index.js                          # koa server
    styles/                             # css
      mystyles.css
    templates/                          # mustache templates
      vars.json                         # variables global to all templates
      views.json                        # array of views to render, can override variables in vars.json
      wireframe.mustache                # base wireframe
      pageA.mustache                    # view partial to be wrapped in wireframe.mustache
      pageB.mustache
  Dockerfile
  gulpfile.js
  package.json
  package-lock.json

Features

CI

When executing npm start without the NODE_ENV environment variable set to production, gulp is instructed to watch changes to source files and automatically rebuild the project.

AMP validation

With each build, the resulting HTML is validated against the AMP standard and the build fails if invalid.

(LD+)JSON

The skeleton is setup so you can inline JSON data, e.g. to add microdata. Put your JSON files into src/json/ and reference them in your HTML via

<script type="application/ld+json" src="my-data.json"></script>

Styles

All stylesheets located in src/styles will be combined, processed by postcss/autoprefixer, minified and inlined into generated HTML files.

Templating

Wireframe

Templates are rendered by including a view partial into the base wireframe.

Please take a look at src/templates/wireframe.mustache and adjust it according to your needs.

Adding pages/views

When you add a new page/view, it needs to be configured in src/templates/views.json. This file contains an array of all views/pages to publish. Each entry in the array is an object with the following signature:

{
  "name": "pagename",
  "vars": {
    "href": "/path/to/this/page",
    // ...
  }
}

The important parts are the name and the vars.href property. The build process will create the path referenced in vars.href in the dist/ directory and render the view into an index.html file therein. By convention the build task looks for a partial named pagename.mustache in the src/templates directory.

Please look at src/templates/views.json for some basic examples.

Variables

Variables global to all templates are set in src/templates/vars.json. Any variable can be overriden by a view via the vars property in src/templates/views.json.

Please look at src/templates/vars.json and src/templates/views.json for some basic examples.

Server

This skeleton comes equipped with a environment aware Koa server with compression and basic caching enabled. Configure the server via the following environment variables:

  • PORT [default: 8080]
  • COMPRESSION_THRESHOLD [default: 0]
  • CACHE_MAXAGE: [default: 60000 (= 1 minute)]

Please have a look at src/server/index.js and adjust according to your needs.

Docker

This skeleton provides a rudimentary Dockerfile

Changelog

License