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

ssg

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssg

a very experimental static site generator overlay on top of Sapper. For a simple demo see this:

  • 0.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-68.24%
Maintainers
1
Weekly downloads
 
Created
Source

Sapper Site Generator

a very experimental static site generator overlay on top of Sapper. For a simple demo see this:

https://www.youtube.com/watch?v=o_o0PAts9Gg&feature=youtu.be

Installation

yarn add sapper svelte ssg

What it expects

  1. you will have a src/routes/data/[slug].json.js file in your main Sapper project, that looks like this:
const { getData } = require('../../../ssg.config')

export async function get(req, res) {
  const { slug } = req.params
  const data = await getData()
  if (data[slug]) {
    res.writeHead(200, { 'Content-Type': 'application/json' })
    res.end(JSON.stringify(data[slug]))
  } else {
    res.writeHead(404, { 'Content-Type': 'application/json' })
    res.end(JSON.stringify({ message: `Not found` }))
  }
}
  1. You should have a ssg.config.js that exports a getData function that provides this data:
exports.getData = async () => {
  // do whatever you want
  return {
    index: [{ title: 'foo', slug: 'foo' }, { title: 'bar', slug: 'bar' }],
    foo: { title: 'foo', html: '<div> the foo post </div>' },
    bar: { title: 'bar', html: '<div> the bar post </div>' },
  }
}

What it does

Under the hood, ssg runs sapper dev for you, and watches and reloads it whenever you change your config or contents folder.

Keywords

FAQs

Package last updated on 14 Sep 2019

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