Get the date from the TOML posts too.

This commit is contained in:
Jessica Canady 2024-05-23 16:48:53 -04:00
parent 523b36d823
commit 441bc58cf8
Signed by: phoenix
SSH key fingerprint: SHA256:aaLOzOrLi+0n4eDZNQKH97PehwRt6KSE5fYJc+ZRKCQ
2 changed files with 5 additions and 4 deletions

View file

@ -20,7 +20,8 @@ defmodule JOL.Blog.Parser do
parsed_attrs = %{ parsed_attrs = %{
title: toml_attrs["title"], title: toml_attrs["title"],
draft: toml_attrs["draft"], draft: toml_attrs["draft"],
tags: toml_attrs["taxonomies"]["tags"] tags: toml_attrs["taxonomies"]["tags"],
date: toml_attrs["date"]
} }
parsed_body = String.trim(body) parsed_body = String.trim(body)

View file

@ -37,8 +37,8 @@ defmodule JOL.Blog.ParserTest do
assert post.attrs.draft == false assert post.attrs.draft == false
end end
test "parses the attrs from zola-style posts", post do test "parses the publish date from zola-style posts", post do
{attrs, _body} = Parser.parse("filepath", post.content) {:ok, known_date, _} = DateTime.from_iso8601("2024-01-02 14:00:00-05:00")
assert attrs == %{title: "test post", draft: false, tags: ["howto", "hardware"]} assert Date.compare(known_date, post.attrs.date) == :eq
end end
end end