| [7bc636b] | 1 | <%
|
|---|
| 2 | // Homepage — feed of posts.
|
|---|
| 3 | //
|
|---|
| 4 | // Renders BOTH a timeline view (.post-list, default) AND a grid view
|
|---|
| 5 | // (.feed-grid, square Instagram-style tiles). CSS toggles between the
|
|---|
| 6 | // two based on body[data-feed-view="timeline"|"grid"]. This mirrors the
|
|---|
| 7 | // v9 pattern in lib/template-content.php so the same view-switcher works.
|
|---|
| 8 | //
|
|---|
| 9 | // Pinned posts sort first inside the timeline list; they are not given a
|
|---|
| 10 | // separate "Pinned" header (v9 just lets order speak for itself + a ★ chip).
|
|---|
| 11 |
|
|---|
| 12 | const allPosts = [...pinnedPosts, ...posts];
|
|---|
| [b94c08e] | 13 | const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
|
|---|
| [7bc636b] | 14 | %>
|
|---|
| 15 |
|
|---|
| 16 | <%# View switcher used to be rendered here; moved to shell.ejs (above
|
|---|
| 17 | #pcms-main) so it survives HTMX swaps and is visible on every
|
|---|
| 18 | non-admin page. %>
|
|---|
| 19 |
|
|---|
| 20 | <!-- ========== TIMELINE ========== -->
|
|---|
| 21 | <div class="container feed-timeline">
|
|---|
| 22 |
|
|---|
| 23 | <% if (allPosts.length === 0) { %>
|
|---|
| 24 | <div class="empty">
|
|---|
| [4885eab] | 25 | <h1><%= t('phome.empty_title') %></h1>
|
|---|
| 26 | <p><%= t('phome.empty_sub') %></p>
|
|---|
| [8afbdd6] | 27 | <% if (user && canMutate && permissions.canCreatePost(user, site)) { %>
|
|---|
| [7bc636b] | 28 | <p style="margin-top:2rem">
|
|---|
| [b94c08e] | 29 | <a class="btn" href="<%= _base %>/posts/new"
|
|---|
| 30 | hx-get="<%= _base %>/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
|
|---|
| 31 | hx-push-url="<%= _base %>/posts/new" hx-indicator="#pcms-loading">
|
|---|
| [4885eab] | 32 | <%= t('phome.write_first') %> →
|
|---|
| [7bc636b] | 33 | </a>
|
|---|
| 34 | </p>
|
|---|
| 35 | <% } %>
|
|---|
| 36 | </div>
|
|---|
| 37 | <% } else { %>
|
|---|
| [520e477] | 38 | <ul class="post-list feed-timeline-list" id="post-list">
|
|---|
| [7bc636b] | 39 | <% allPosts.forEach(function(post) { %>
|
|---|
| 40 | <%- include('../partials/post-card', { post: post }) %>
|
|---|
| 41 | <% }); %>
|
|---|
| 42 | </ul>
|
|---|
| 43 | <% } %>
|
|---|
| 44 |
|
|---|
| 45 | </div>
|
|---|
| 46 |
|
|---|
| 47 | <!-- ========== GRID (only visible when body[data-feed-view="grid"]) ========== -->
|
|---|
| 48 | <% if (allPosts.length > 0) { %>
|
|---|
| [4885eab] | 49 | <section class="feed-grid container" aria-label="<%= t('phome.grid_view') %>">
|
|---|
| [520e477] | 50 | <div class="grid-tiles" id="grid-tiles">
|
|---|
| [7bc636b] | 51 | <% allPosts.forEach(function(post) { %>
|
|---|
| 52 | <%- include('../partials/post-tile', { post: post }) %>
|
|---|
| 53 | <% }); %>
|
|---|
| 54 | </div>
|
|---|
| 55 | </section>
|
|---|
| 56 | <% } %>
|
|---|
| [520e477] | 57 | <% if (typeof hasMore !== 'undefined' && allPosts.length > 0) { %>
|
|---|
| 58 | <div class="container feed-more-wrap">
|
|---|
| 59 | <%- include('../partials/load-more', { hasMore: hasMore, nextOffset: nextOffset, moreBase: moreBase, moreTarget: '#post-list', morePath: '/' }) %>
|
|---|
| 60 | </div>
|
|---|
| 61 | <% } %>
|
|---|