41 lines
797 B
Gleam
41 lines
797 B
Gleam
import gleam/time/calendar
|
|
import gleeunit
|
|
import gleeunit/should
|
|
import lustre/element
|
|
import promptbox/files
|
|
import promptbox/gen
|
|
import promptbox/parser
|
|
import simplifile
|
|
|
|
pub fn main() {
|
|
gleeunit.main()
|
|
}
|
|
|
|
pub fn parse_basic_post_test() {
|
|
"---
|
|
title: a title
|
|
week: 1
|
|
date: 2025-01-01
|
|
---
|
|
Post content 1
|
|
+++
|
|
Post content 2"
|
|
|> parser.parse_post("a-title", _)
|
|
|> should.equal(parser.Post(
|
|
slug: "a-title",
|
|
title: "a title",
|
|
week: 1,
|
|
date: calendar.Date(2025, calendar.January, 1),
|
|
post_p: "<p>Post content 1</p>\n",
|
|
post_j: "<p>Post content 2</p>\n",
|
|
))
|
|
}
|
|
|
|
pub fn generate_test() {
|
|
let _ = simplifile.create_directory("./dist")
|
|
|
|
files.read_all_posts()
|
|
|> gen.generate_posts
|
|
|> element.to_document_string
|
|
|> simplifile.write(to: "./dist/index.html")
|
|
}
|