2.0.9 • Published 2 years ago

@stageny/base v2.0.9

Weekly downloads
30
License
GPL-3.0-only
Repository
-
Last release
2 years ago

Introduction

Stageny (without plugins) is a basic but powerful static site generator that focuses on performance, versatility and simplicity. It has been born out of the wish for a (node/js only) replacement for Middleman.

It compiles pages written in many templates languages (but prefering PUG) into HTML. It does not compile to CSS or JS or anything else.

A page is built with those 4 elements

Pages

A page has two parts: frontmatter data and the actual template. (JS is slightly special, see below).

The frontmatter will be parsed right away so you can use it for routing / sitemap. It will be accessible in templates via _meta. Put into data what you want to populate to the merged data object.

i-am-a-page.html.pug

---
title: I am a page
data:
  date*: new Date()
layout: default
---

h1 #{_meta.title} from #{date.toLocaleString()}
p With not much content

or i-am-a-page.html.js

module.exports = {
	 data: {
		 title: 'I am a page',
		 layout: 'default',
		 data: {
		 	date: () => new Date()
		 }
	 },
	 render(data) {
		 return `
			<h1>${data._meta.title} from ${data.date}</h1>
			<p>With not much content</p>
		`
	 }
}

Stageny in its core supports Components and Layouts.

Layouts

A page's frontmatter layout: default points to a specific layout:

layouts/default.pug:

html
	head
		title #{_meta.title}
	body
		!= content

A layout too can have frontmatter which will be overruled by the page (except for layout which you use to define a super layout).

Components

Components must be uniquely named, no matter their file path. Frontmatter serves as default paramters.

components/Button.pug:

---
tag: button
content: Button
---

#{tag}.Button(type=(tag === 'button' && tag))!= content

content is a special parameter, at least in pug, as the slot will be put into it.

page.html.pug:

+Component('Button')
	i.Icon(data-icon="plus")
	| Add

page.html.js:

module.exports = function(data) {
	return data.component('Button', {
		content: `<i class="Icon" data-icon="plus"></i> Add`
	})
}

Data

Data can be global or on a page level.

Data will be applied in this order:

  • _page and internal component helper
  • data and _data (if Data Plugin)
  • helpers and _helpers (if Helper Plugin)
  • page frontmatter (also via _page.meta)

Page

  • url
  • meta
  • content
  • result
  • render
  • rawMeta

Events / Plugins

Plugins (and helpers) can sneak into any of those events:

  • init (before first run)
  • on every run: - start - sitemap (array of pages) - for every page: - beforepageprocess (file) - beforepagedata (file, data) - afterpagedata (file, data) - beforepagerender (file) - afterpagerender (file) - afterpagewrite (file) - pageerror (file) - end
2.0.2

2 years ago

2.0.5

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.5

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.2

2 years ago

1.1.0

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago