Add current_tag attribute to post_index component
This commit is contained in:
parent
cf7df3111f
commit
17a0f2709c
@ -23,9 +23,11 @@ defmodule Blogex.Components do
|
|||||||
|
|
||||||
* `:posts` - list of `%Blogex.Post{}` structs (required)
|
* `:posts` - list of `%Blogex.Post{}` structs (required)
|
||||||
* `:base_path` - base URL path for post links (required)
|
* `:base_path` - base URL path for post links (required)
|
||||||
|
* `:current_tag` - currently selected tag for highlighting (optional)
|
||||||
"""
|
"""
|
||||||
attr :posts, :list, required: true
|
attr :posts, :list, required: true
|
||||||
attr :base_path, :string, required: true
|
attr :base_path, :string, required: true
|
||||||
|
attr :current_tag, :string, default: nil
|
||||||
|
|
||||||
def post_index(assigns) do
|
def post_index(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
@ -35,7 +37,7 @@ defmodule Blogex.Components do
|
|||||||
<h2>
|
<h2>
|
||||||
<a href={"#{@base_path}/#{post.id}"}>{post.title}</a>
|
<a href={"#{@base_path}/#{post.id}"}>{post.title}</a>
|
||||||
</h2>
|
</h2>
|
||||||
<.post_meta post={post} base_path={@base_path} />
|
<.post_meta post={post} base_path={@base_path} current_tag={@current_tag} />
|
||||||
</header>
|
</header>
|
||||||
<p class="blogex-post-description">{post.description}</p>
|
<p class="blogex-post-description">{post.description}</p>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user