Socket
Socket
Sign inDemoInstall

vanilla-ssg

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-ssg

A very minimalistic, single function static site generator based on ES6 template strings.


Version published
Maintainers
1
Created
Source

Vanilla-SSG

A very minimalistic, single function static site generator based on ES6 template strings.

It makes use of the minimalistic renderly package (https://github.com/gcazaciuc/renderly) for rendering the templates.

Getting started

Install the vanilla-ssg package:

npm i vanilla-ssg

The vanilla-ssg package is meant to be used programatically in order to generate static sites.

This is the simplest and most flexible way.

After installing, create a Javascript file that will contain the code for the generator.

Let's call it generate.js :

const { createPage } = require("vanilla-ssg");

const createClient = require("../HttpClient");
const client = createClient();

(async function() {
  const posts = await client.get("https://jsonplaceholder.typicode.com/posts");

  createPage(`posts`, { posts }, `examples/posts.tpl`);
  posts.forEach(post => {
    createPage(`posts/${post.id}`, post, `examples/post.tpl`);
  });
})();

There is a single API method called createPage taking in the page url, page data and the template to apply. It's output is an HTML file that is written to disk.

The purpose of the script is to retrieve any needed data to generate the site and to call createPage API in order to create the HTML.

Keywords

FAQs

Package last updated on 29 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc