This commit is contained in:
parent
0f5ec5fd9c
commit
e0e2691150
4 changed files with 17 additions and 15 deletions
|
|
@ -1,15 +1,16 @@
|
|||
import gleam/list
|
||||
import gleam/order
|
||||
import promptbox/parser
|
||||
import gleam/list
|
||||
import simplifile
|
||||
|
||||
pub fn read_all_posts() {
|
||||
let assert Ok(posts) = simplifile.read_directory("./priv/posts")
|
||||
|
||||
let posts = list.map(posts, fn(p) {
|
||||
let assert Ok(content) = simplifile.read("./priv/posts/" <> p)
|
||||
parser.parse_post(content)
|
||||
})
|
||||
let posts =
|
||||
list.map(posts, fn(p) {
|
||||
let assert Ok(content) = simplifile.read("./priv/posts/" <> p)
|
||||
parser.parse_post(content)
|
||||
})
|
||||
use a, b <- list.sort(posts)
|
||||
|
||||
case a.week >= b.week {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import promptbox/web
|
||||
import promptbox/parser
|
||||
import promptbox/web
|
||||
|
||||
pub fn generate_posts(posts: List(parser.Post)) {
|
||||
web.home(posts)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ fn prompt_element(post: parser.Post) {
|
|||
html.div([attribute.class("grid lg:grid-cols-2 gap-6")], [
|
||||
html.div([attribute("dangerous-unescaped-html", post.post_p)], []),
|
||||
html.div([attribute("dangerous-unescaped-html", post.post_j)], []),
|
||||
])
|
||||
]),
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import lustre/element
|
||||
import promptbox/gen
|
||||
import promptbox/files
|
||||
import birl
|
||||
import gleam/io
|
||||
import gleam/result
|
||||
import gleeunit
|
||||
import gleeunit/should
|
||||
import lustre/element
|
||||
import promptbox/files
|
||||
import promptbox/gen
|
||||
import promptbox/parser
|
||||
import simplifile
|
||||
|
||||
|
|
@ -15,10 +15,11 @@ pub fn main() {
|
|||
|
||||
// gleeunit test functions end in `_test`
|
||||
pub fn hello_world_test() {
|
||||
let post = simplifile.read("./priv/posts/ebb_and_flow.md")
|
||||
|> result.unwrap("")
|
||||
|> parser.parse_post
|
||||
|> io.debug
|
||||
let post =
|
||||
simplifile.read("./priv/posts/ebb_and_flow.md")
|
||||
|> result.unwrap("")
|
||||
|> parser.parse_post
|
||||
|> io.debug
|
||||
|
||||
io.debug(birl.to_date_string(post.date))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue