Let’s talk about the Future of Jamstack — Join us

Sphido

33 stars
0 forks
0 issues
Home page
https://sphido.org/
Repository
sphido/sphido
Twitter
@sphidocms
Language:
JavaScript,Node.js
License:
MIT
Templates:
Any JS

I know, another static site generator! This one is different - it's totally minimalistic. Basically, it's just two functions. The first, the getPages() function, allows you to retrieve a list of pages, and the allPages() function allows you to iterate through them.

You get a static site generator that is:

  • 🚀 rocket fast
  • 💭️ light-weight
  • 🤘 no dependencies
  • ⚡️ flexible

Supports

  • YAML front-matter
  • html/markdown source files
  • custom extenders
  • any JS templates

Installation

yarn add @sphido/core # that's all

Usage

#!/usr/bin/env node

import {dirname, relative, join} from 'node:path';
import {getPages, allPages, readFile, writeFile} from '@sphido/core';
import slugify from '@sindresorhus/slugify';
import {marked} from 'marked';

const pages = await getPages({path: 'content'}, // ... extenders
	(page) => {
		page.slug = slugify(page.name) + '.html';
		page.dir = dirname(page.path);
	});

for (const page of allPages(pages)) {
	page.output = join('public', relative('content', page.dir), page.slug);
	page.content = marked(await readFile(page.path));
	await writeFile(page.output, `<!DOCTYPE html>
        <html lang="en" dir="ltr">
        <head>
            <meta charset="UTF-8">
            <script src="https://cdn.tailwindcss.com?plugins=typography"></script>
            <title>${page.name} | Sphido Example</title>
        </head>
        <body class="prose mx-auto my-6">${page.content}</body>
        <!-- Generated by Sphido from ${page.path} -->
        </html>
    `);
}

Run script

node index.js

Need more examples?

Let's look at the source code of sphido.org or the examples repository.

Find more static site generators.