2024-04-20 20:03:30 +00:00
|
|
|
# scriptorium
|
2024-04-04 11:42:55 +00:00
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
Scriptorium is a simple blog generator for Gleam, using [Lustre](https://hexdocs.pm/lustre) and
|
2024-04-20 08:25:02 +00:00
|
|
|
[lustre_ssg](https://hexdocs.pm/lustre_ssg).
|
2024-04-04 11:42:55 +00:00
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
Scriptorium runs on the JavaScript target and it's tested with Node.js.
|
2024-04-20 08:25:02 +00:00
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
[![Package Version](https://img.shields.io/hexpm/v/scriptorium)](https://hex.pm/packages/scriptorium)
|
|
|
|
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/scriptorium/)
|
2024-04-20 08:25:02 +00:00
|
|
|
|
|
|
|
## Quickstart
|
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
To use Scriptorium, you will need to create a new Gleam project and add Scriptorium as a
|
|
|
|
dependency.
|
2024-04-20 08:25:02 +00:00
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
```sh
|
|
|
|
gleam add scriptorium
|
2024-04-04 11:42:55 +00:00
|
|
|
```
|
2024-04-20 08:25:02 +00:00
|
|
|
|
|
|
|
To generate a default blog, use the following in your main file:
|
|
|
|
|
2024-04-04 11:42:55 +00:00
|
|
|
```gleam
|
2024-04-20 08:25:02 +00:00
|
|
|
import gleam/result
|
|
|
|
import gleam/option
|
|
|
|
import gleam/io
|
2024-04-20 20:03:30 +00:00
|
|
|
import scriptorium/builder
|
|
|
|
import scriptorium/config.{type Configuration, Configuration}
|
|
|
|
import scriptorium/defaults
|
2024-04-04 11:42:55 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2024-04-20 08:25:02 +00:00
|
|
|
let config =
|
|
|
|
defaults.default_config(
|
|
|
|
"My Blog",
|
|
|
|
"https://my.blog.example/",
|
|
|
|
"en",
|
|
|
|
config.Author(
|
|
|
|
"Person McPerson",
|
|
|
|
option.Some("person@example.com"),
|
|
|
|
option.Some("https://fedi.instance.example/@person"),
|
|
|
|
),
|
|
|
|
"© Person McPerson",
|
|
|
|
)
|
|
|
|
|
|
|
|
io.debug(build(config))
|
2024-04-04 11:42:55 +00:00
|
|
|
}
|
|
|
|
|
2024-04-20 08:25:02 +00:00
|
|
|
pub fn build(config: Configuration) {
|
|
|
|
// Parse the files
|
|
|
|
use db <- result.try(builder.parse(config))
|
|
|
|
// Compile Markdown into HTML
|
|
|
|
let compiled = builder.compile(db, config)
|
|
|
|
// Render content into Lustre elements
|
|
|
|
let rendered = builder.render(db, compiled, config)
|
|
|
|
// Write rendered content into the filesystem
|
|
|
|
builder.write(rendered, config)
|
|
|
|
}
|
|
|
|
```
|
2024-04-04 11:42:55 +00:00
|
|
|
|
2024-04-20 08:25:02 +00:00
|
|
|
## Documentation
|
2024-04-04 11:42:55 +00:00
|
|
|
|
2024-04-20 20:03:30 +00:00
|
|
|
- [Scriptorium Demo Blog](https://nicd.gitlab.io/scriptorium_blog)
|
|
|
|
- [User's Guide](https://nicd.gitlab.io/scriptorium_blog/guide.html)
|
|
|
|
- [Scriptorium API reference](https://hexdocs.pm/scriptorium)
|