refactor: extract post feed logic into reusable partial
All checks were successful
Deploy Theme / deploy (push) Successful in 13s
All checks were successful
Deploy Theme / deploy (push) Successful in 13s
This commit is contained in:
25
author.hbs
25
author.hbs
@@ -61,26 +61,9 @@
|
|||||||
{{/author}}
|
{{/author}}
|
||||||
|
|
||||||
<div class="container mx-auto px-4 pb-20">
|
<div class="container mx-auto px-4 pb-20">
|
||||||
<div id="posts-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10">
|
{{#if posts}}
|
||||||
{{#foreach posts}}
|
{{> "post-feed"}}
|
||||||
{{> "post-card"}}
|
{{else}}
|
||||||
{{/foreach}}
|
<p class="text-center text-[var(--text-secondary)] text-2xl py-20">No posts found.</p>
|
||||||
|
|
||||||
{{#if pagination.next}}
|
|
||||||
<div id="pagination-trigger"
|
|
||||||
hx-get="{{page_url pagination.next}}"
|
|
||||||
hx-trigger="revealed"
|
|
||||||
hx-select="#posts-container > *"
|
|
||||||
hx-target="this"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#loading-spinner"
|
|
||||||
class="col-span-full h-1">
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loading-spinner" class="htmx-indicator text-center py-12">
|
|
||||||
<div class="inline-block animate-spin rounded-full h-10 w-10 border-4 border-[var(--brand-primary)] border-t-transparent"></div>
|
|
||||||
<p class="text-[var(--text-secondary)] mt-4 font-medium tracking-wide">Loading more posts...</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|||||||
24
index.hbs
24
index.hbs
@@ -7,29 +7,7 @@
|
|||||||
|
|
||||||
<div class="container mx-auto px-4 pb-20">
|
<div class="container mx-auto px-4 pb-20">
|
||||||
{{#if posts}}
|
{{#if posts}}
|
||||||
<div id="posts-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10">
|
{{> "post-feed"}}
|
||||||
{{#foreach posts}}
|
|
||||||
{{> "post-card"}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{#if pagination.next}}
|
|
||||||
<div id="pagination-trigger"
|
|
||||||
hx-get="{{page_url pagination.next}}"
|
|
||||||
hx-trigger="revealed"
|
|
||||||
hx-select="#posts-container > *"
|
|
||||||
hx-target="this"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#loading-spinner"
|
|
||||||
class="col-span-full h-1">
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="loading-spinner" class="htmx-indicator text-center py-12">
|
|
||||||
<div class="inline-block animate-spin rounded-full h-10 w-10 border-4 border-[var(--brand-primary)] border-t-transparent"></div>
|
|
||||||
<p class="text-[var(--text-secondary)] mt-4 font-medium tracking-wide">Loading more posts...</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<p class="text-center text-[var(--text-secondary)] text-2xl py-20">No posts found.</p>
|
<p class="text-center text-[var(--text-secondary)] text-2xl py-20">No posts found.</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
22
partials/post-feed.hbs
Normal file
22
partials/post-feed.hbs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<div id="posts-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10">
|
||||||
|
{{#foreach posts}}
|
||||||
|
{{> "post-card"}}
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
|
{{#if pagination.next}}
|
||||||
|
<div id="pagination-trigger"
|
||||||
|
hx-get="{{page_url pagination.next}}"
|
||||||
|
hx-trigger="revealed"
|
||||||
|
hx-select="#posts-container > *"
|
||||||
|
hx-target="this"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-indicator="#loading-spinner"
|
||||||
|
class="col-span-full h-1">
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="loading-spinner" class="htmx-indicator text-center py-12">
|
||||||
|
<div class="inline-block animate-spin rounded-full h-10 w-10 border-4 border-[var(--brand-primary)] border-t-transparent"></div>
|
||||||
|
<p class="text-[var(--text-secondary)] mt-4 font-medium tracking-wide">Loading more posts...</p>
|
||||||
|
</div>
|
||||||
24
tag.hbs
24
tag.hbs
@@ -18,29 +18,7 @@
|
|||||||
|
|
||||||
<div class="container mx-auto px-4 pb-20">
|
<div class="container mx-auto px-4 pb-20">
|
||||||
{{#if posts}}
|
{{#if posts}}
|
||||||
<div id="posts-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10">
|
{{> "post-feed"}}
|
||||||
{{#foreach posts}}
|
|
||||||
{{> "post-card"}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{#if pagination.next}}
|
|
||||||
<div id="pagination-trigger"
|
|
||||||
hx-get="{{page_url pagination.next}}"
|
|
||||||
hx-trigger="revealed"
|
|
||||||
hx-select="#posts-container > *"
|
|
||||||
hx-target="this"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#loading-spinner"
|
|
||||||
class="col-span-full h-1">
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="loading-spinner" class="htmx-indicator text-center py-12">
|
|
||||||
<div class="inline-block animate-spin rounded-full h-10 w-10 border-4 border-[var(--brand-primary)] border-t-transparent"></div>
|
|
||||||
<p class="text-[var(--text-secondary)] mt-4 font-medium tracking-wide">Loading more posts...</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<p class="text-center text-[var(--text-secondary)] text-2xl py-20">No posts found.</p>
|
<p class="text-center text-[var(--text-secondary)] text-2xl py-20">No posts found.</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
Reference in New Issue
Block a user