0.0.1 • Published 3 years ago
@static-pages/pug-writer v0.0.1
Static Pages / Pug Writer
Renders page data via pug templates.
Uses the Pug package under the hood.
This package is part of the StaticPagesJs project, see:
- Documentation: staticpagesjs.github.io
- Core: @static-pages/core
Options
| Option | Type | Default value | Description |
|---|---|---|---|
view | string \| (d: Data) => string | main.pug | Template to render. If it's a function it gets evaluated on each render call. |
outDir | string | dist | Directory where the rendered output is saved. |
outFile | string \| (d: Data) => string | see outFile section | Path of the rendered output relative to outDir. |
onOverwrite | (d: string) => void | console.warn(...) | Callback function that gets executed when a file name collision occurs. |
onInvalidPath | (d: string) => void | console.warn(...) | Callback function that gets executed when a file name contains invalid characters. |
pugOptions | pug.Options | {} | Allows you to configure pug renderer. |
showdownEnabled | boolean | true | Register a markdown function; uses showdown. |
showdownOptions | showdown.ConverterOptions | see showdownOptions section | Custom options for the showdown markdown renderer. |
Example markdown usage
!= markdown('my something')outFile defaults
The default behaviour is to guess file path by a few possible properties of the data:
- if
data.urlis defined, append.htmland use that. - if
data.header.pathis defined, replace extension to.htmland use that. - if nothing matches call the
onInvalidPathhandler withundefinedfile name.
showdownOptions defaults
This package uses a sligthly modified defaults compared to the official Showdown defaults:
{
simpleLineBreaks: true,
ghCompatibleHeaderId: true,
customizedHeaderId: true,
tables: true,
}0.0.1
3 years ago