scriptorium/README.md
2024-04-20 11:25:02 +03:00

65 lines
1.8 KiB
Markdown

# gloss
Gloss is a simple blog generator for Gleam, using [Lustre](https://hexdocs.pm/lustre) and
[lustre_ssg](https://hexdocs.pm/lustre_ssg).
Gloss runs on the JavaScript target and it's tested with Node.js.
<!-- [![Package Version](https://img.shields.io/hexpm/v/gloss)](https://hex.pm/packages/gloss) -->
<!-- [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gloss/) -->
## Quickstart
Gloss is not yet available on Hex. You can use it with a path dependency instead. Create a new
Gleam project and add the following to `gleam.toml`:
```toml
[dependencies]
gleam_stdlib = "~> 0.36 or ~> 1.0"
gloss = { path = "../path/to/gloss" }
```
To generate a default blog, use the following in your main file:
```gleam
import gleam/result
import gleam/option
import gleam/io
import gloss/builder
import gloss/config.{type Configuration, Configuration}
import gloss/defaults
pub fn main() {
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))
}
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)
}
```
## Documentation
- [Gloss Demo Blog](https://nicd.gitlab.io/gloss_blog)
- [User's Guide](https://nicd.gitlab.io/gloss_blog/guide.html)
- [Gloss API reference](https://nicd.gitlab.io/gloss)