From 441bc58cf8c73bbe754a01f1792f0a0ecabe543c Mon Sep 17 00:00:00 2001 From: Jessica Phoenix Canady Date: Thu, 23 May 2024 16:48:53 -0400 Subject: [PATCH] Get the date from the TOML posts too. --- lib/jol/blog/parser.ex | 3 ++- test/lib/blog/parser_test.exs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jol/blog/parser.ex b/lib/jol/blog/parser.ex index f303adf..cf61892 100644 --- a/lib/jol/blog/parser.ex +++ b/lib/jol/blog/parser.ex @@ -20,7 +20,8 @@ defmodule JOL.Blog.Parser do parsed_attrs = %{ title: toml_attrs["title"], draft: toml_attrs["draft"], - tags: toml_attrs["taxonomies"]["tags"] + tags: toml_attrs["taxonomies"]["tags"], + date: toml_attrs["date"] } parsed_body = String.trim(body) diff --git a/test/lib/blog/parser_test.exs b/test/lib/blog/parser_test.exs index 1d22aa5..219db4a 100644 --- a/test/lib/blog/parser_test.exs +++ b/test/lib/blog/parser_test.exs @@ -37,8 +37,8 @@ defmodule JOL.Blog.ParserTest do assert post.attrs.draft == false end - test "parses the attrs from zola-style posts", post do - {attrs, _body} = Parser.parse("filepath", post.content) - assert attrs == %{title: "test post", draft: false, tags: ["howto", "hardware"]} + test "parses the publish date from zola-style posts", post do + {:ok, known_date, _} = DateTime.from_iso8601("2024-01-02 14:00:00-05:00") + assert Date.compare(known_date, post.attrs.date) == :eq end end