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 gleam/order
|
||||||
import promptbox/parser
|
import promptbox/parser
|
||||||
import gleam/list
|
|
||||||
import simplifile
|
import simplifile
|
||||||
|
|
||||||
pub fn read_all_posts() {
|
pub fn read_all_posts() {
|
||||||
let assert Ok(posts) = simplifile.read_directory("./priv/posts")
|
let assert Ok(posts) = simplifile.read_directory("./priv/posts")
|
||||||
|
|
||||||
let posts = list.map(posts, fn(p) {
|
let posts =
|
||||||
let assert Ok(content) = simplifile.read("./priv/posts/" <> p)
|
list.map(posts, fn(p) {
|
||||||
parser.parse_post(content)
|
let assert Ok(content) = simplifile.read("./priv/posts/" <> p)
|
||||||
})
|
parser.parse_post(content)
|
||||||
|
})
|
||||||
use a, b <- list.sort(posts)
|
use a, b <- list.sort(posts)
|
||||||
|
|
||||||
case a.week >= b.week {
|
case a.week >= b.week {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import promptbox/web
|
|
||||||
import promptbox/parser
|
import promptbox/parser
|
||||||
|
import promptbox/web
|
||||||
|
|
||||||
pub fn generate_posts(posts: List(parser.Post)) {
|
pub fn generate_posts(posts: List(parser.Post)) {
|
||||||
web.home(posts)
|
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.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_p)], []),
|
||||||
html.div([attribute("dangerous-unescaped-html", post.post_j)], []),
|
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 birl
|
||||||
import gleam/io
|
import gleam/io
|
||||||
import gleam/result
|
import gleam/result
|
||||||
import gleeunit
|
import gleeunit
|
||||||
import gleeunit/should
|
import gleeunit/should
|
||||||
|
import lustre/element
|
||||||
|
import promptbox/files
|
||||||
|
import promptbox/gen
|
||||||
import promptbox/parser
|
import promptbox/parser
|
||||||
import simplifile
|
import simplifile
|
||||||
|
|
||||||
|
|
@ -15,10 +15,11 @@ pub fn main() {
|
||||||
|
|
||||||
// gleeunit test functions end in `_test`
|
// gleeunit test functions end in `_test`
|
||||||
pub fn hello_world_test() {
|
pub fn hello_world_test() {
|
||||||
let post = simplifile.read("./priv/posts/ebb_and_flow.md")
|
let post =
|
||||||
|> result.unwrap("")
|
simplifile.read("./priv/posts/ebb_and_flow.md")
|
||||||
|> parser.parse_post
|
|> result.unwrap("")
|
||||||
|> io.debug
|
|> parser.parse_post
|
||||||
|
|> io.debug
|
||||||
|
|
||||||
io.debug(birl.to_date_string(post.date))
|
io.debug(birl.to_date_string(post.date))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue