Filter future-dated posts from public views and add unfiltered post access
- all_posts/0 now excludes posts where date > today - all_tags/0 computed at runtime from filtered posts - posts_by_tag/1 and recent_posts/1 inherit date filtering - Add unfiltered_posts/0 to Blog macro and FakeBlog - Add all_posts_unfiltered/0 to Registry for dashboard use
This commit is contained in:
@@ -51,9 +51,16 @@ defmodule Blogex.Test.FakeBlog do
|
||||
def description, do: get(:description)
|
||||
def base_path, do: get(:base_path)
|
||||
|
||||
def all_posts do
|
||||
def unfiltered_posts do
|
||||
get(:posts)
|
||||
|> Enum.filter(& &1.published)
|
||||
|> Enum.sort_by(& &1.date, {:desc, Date})
|
||||
end
|
||||
|
||||
def all_posts do
|
||||
today = Date.utc_today()
|
||||
|
||||
get(:posts)
|
||||
|> Enum.filter(&(&1.published and not Date.after?(&1.date, today)))
|
||||
|> Enum.sort_by(& &1.date, {:desc, Date})
|
||||
end
|
||||
|
||||
|
||||
@@ -44,6 +44,12 @@ defmodule Blogex.Test.Setup do
|
||||
date: ~D[2026-03-12],
|
||||
tags: ["elixir"],
|
||||
published: false
|
||||
),
|
||||
build(
|
||||
id: "future-post",
|
||||
date: ~D[2099-01-01],
|
||||
tags: ["future-only"],
|
||||
published: true
|
||||
)
|
||||
]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user