diff --git a/lib/jol_web/components/blog.ex b/lib/jol_web/components/blog.ex new file mode 100644 index 0000000..d153c12 --- /dev/null +++ b/lib/jol_web/components/blog.ex @@ -0,0 +1,11 @@ +defmodule JOLWeb.Components.Blog do + @moduledoc """ + This module holds various ways of rendering a `JOL.Blog.Post`. + + See the `blog` directory for the available templates.` + """ + + use JOLWeb, :html + + embed_templates "blog/*" +end diff --git a/lib/jol_web/components/blog/post_summary.html.heex b/lib/jol_web/components/blog/post_summary.html.heex new file mode 100644 index 0000000..1be9749 --- /dev/null +++ b/lib/jol_web/components/blog/post_summary.html.heex @@ -0,0 +1,3 @@ +
+

<%= @post.title %>

+
diff --git a/lib/jol_web/components/blog/summary.html.heex b/lib/jol_web/components/blog/summary.html.heex new file mode 100644 index 0000000..5fa447f --- /dev/null +++ b/lib/jol_web/components/blog/summary.html.heex @@ -0,0 +1,3 @@ +
+

<%= @blog.title %>

+
diff --git a/test/lib/blog/post_test.ex b/test/lib/blog/post_test.ex new file mode 100644 index 0000000..18ef4ab --- /dev/null +++ b/test/lib/blog/post_test.ex @@ -0,0 +1,33 @@ +defmodule JOL.Blog.PostTest do + use ExUnit.Case, async: true + alias JOL.Blog.Post + + setup do + attrs = %{ + title: "Test Post", + tags: ["testing", "post"], + date: ~D[1999-09-09], + slug: "test-post" + } + + {:ok, attrs: attrs} + end + + test "extracts ledes from delimiters", %{attrs: attrs} do + body = """ + lede goes here + + not this though. + """ + + post = Post.build("filename", attrs, body) + assert post.lede == "lede goes here" + end + + test "extract ledes without delimiters", %{attrs: attrs} do + body = Enum.map_join(1..100, &("Word#{&1} ")) + post = Post.build("filename", attrs, body) + assert String.split(post.lede) |> Enum.count == 50 + end + + end diff --git a/test/lib/blog_test.ex b/test/lib/blog_test.ex new file mode 100644 index 0000000..8346b02 --- /dev/null +++ b/test/lib/blog_test.ex @@ -0,0 +1,7 @@ +defmodule JOL.BlogTest do + use ExUnit.Case, async: true + + setup do + {:ok, %{}} + end +end