Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lukecjohnson/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

@lukecjohnson/ssg

A static site generator that does just enough.

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@lukecjohnson/ssg

A static site generator that does just enough.

Installation

$ npm install @lukecjohnson/ssg --save-dev

Directory structure

2 core directories are required:

  • posts: Should contain Markdown files for all of a site's content
  • templates: Should contain Nunjucks templates for all of a site's pages

The only required template is _post.njk, which is used to generate pages for each post.

Templating

Nunjucks is used for templating ― refer to Nunjucks' templating documentation for detailed usage instructions.

Every template's context includes posts, an array containing each post with any data provided in a post's front matter and the following default properties:

  • content: The rendered HTML body of the post
  • url: The url path for the post
  • date: The date the post was created or the custom date provided in the post's front matter
<h1>Blog</h1>
<ul>
  {% for post in posts %}
    <li><a href="{{ post.url }}">{{ post.title }}</a></li>
  {% endfor %}
</ul>

Additionally, _post.njk has direct access to the properties of an individual post:

<header>
  <h1>{{ title }}</h1>
  <time>{{ date | format('MMMM d, yyyy') }}</time>
</header>
<main>
  {{ content | safe }}
</main>

CLI

To build a site, use the base ssg command. See --help for all available options:


Usage: ssg [options]

Options:

  --output              Path to output directory (Default: ./public)

  --templates           Path to templates directory (Default: ./templates)

  --posts               Path to posts directory (Default: ./posts)

  --posts-base-url      Base URL for posts (Default: /posts)

  --build-drafts        Include posts marked as drafts

  --version             Print version

FAQs

Package last updated on 14 Apr 2021

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