chore(blog-overview): apply prettier formatting
No behavior change — IDE auto-format pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,306 +1,352 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Icon from "@iconify/svelte";
|
import Icon from "@iconify/svelte";
|
||||||
import "$lib/iconify-offline";
|
import "$lib/iconify-offline";
|
||||||
import PostCard from "./PostCard.svelte";
|
import PostCard from "./PostCard.svelte";
|
||||||
import EventBadges from "./EventBadges.svelte";
|
import EventBadges from "./EventBadges.svelte";
|
||||||
import Tag from "./Tag.svelte";
|
import Tag from "./Tag.svelte";
|
||||||
import Pagination from "./Pagination.svelte";
|
import Pagination from "./Pagination.svelte";
|
||||||
import type { PostEntry } from "$lib/cms";
|
import type { PostEntry } from "$lib/cms";
|
||||||
import { postHref } from "$lib/blog-utils";
|
import { postHref } from "$lib/blog-utils";
|
||||||
import { t as tStatic, T } from "$lib/translations";
|
import { t as tStatic, T } from "$lib/translations";
|
||||||
import type { Translations } from "$lib/translations";
|
import type { Translations } from "$lib/translations";
|
||||||
import { fetchCommentCounts, postSlugForComments, type CommentCountsMap } from "$lib/comment-counts";
|
import {
|
||||||
|
fetchCommentCounts,
|
||||||
|
postSlugForComments,
|
||||||
|
type CommentCountsMap,
|
||||||
|
} from "$lib/comment-counts";
|
||||||
|
|
||||||
interface TagEntry {
|
interface TagEntry {
|
||||||
_slug?: string;
|
_slug?: string;
|
||||||
name: string;
|
name: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
}
|
|
||||||
|
|
||||||
type SearchIndexEntry = {
|
|
||||||
slug: string;
|
|
||||||
headline: string;
|
|
||||||
excerpt: string;
|
|
||||||
subheadline: string;
|
|
||||||
tags: string[];
|
|
||||||
image: string | null;
|
|
||||||
created: string | null;
|
|
||||||
isEvent: boolean;
|
|
||||||
eventDate: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
type EventPost = PostEntry & { eventDate?: string; isEvent?: boolean };
|
|
||||||
|
|
||||||
let {
|
|
||||||
posts = [],
|
|
||||||
tags = [],
|
|
||||||
activeTag = null,
|
|
||||||
currentPage = 1,
|
|
||||||
totalPages = 1,
|
|
||||||
totalPosts = 0,
|
|
||||||
basePath = "/posts",
|
|
||||||
translations = {},
|
|
||||||
upcomingEvents = [],
|
|
||||||
searchIndex = null,
|
|
||||||
}: {
|
|
||||||
posts: PostEntry[];
|
|
||||||
tags: TagEntry[];
|
|
||||||
activeTag: string | null;
|
|
||||||
currentPage: number;
|
|
||||||
totalPages: number;
|
|
||||||
totalPosts?: number;
|
|
||||||
basePath?: string;
|
|
||||||
translations?: Translations | null;
|
|
||||||
upcomingEvents?: EventPost[];
|
|
||||||
searchIndex?: SearchIndexEntry[] | null;
|
|
||||||
} = $props();
|
|
||||||
|
|
||||||
let query = $state("");
|
|
||||||
let year = $state<string>("");
|
|
||||||
const normalizedQuery = $derived(query.trim().toLowerCase());
|
|
||||||
const isFiltering = $derived(normalizedQuery.length >= 2 || year !== "");
|
|
||||||
|
|
||||||
function yearOf(entry: SearchIndexEntry): string {
|
|
||||||
const iso = entry.created ?? "";
|
|
||||||
if (!iso) return "";
|
|
||||||
const d = new Date(iso);
|
|
||||||
return Number.isNaN(d.getTime()) ? "" : String(d.getFullYear());
|
|
||||||
}
|
|
||||||
|
|
||||||
const availableYears = $derived.by<string[]>(() => {
|
|
||||||
if (!searchIndex) return [];
|
|
||||||
const set = new Set<string>();
|
|
||||||
for (const p of searchIndex) {
|
|
||||||
const y = yearOf(p);
|
|
||||||
if (y) set.add(y);
|
|
||||||
}
|
}
|
||||||
return Array.from(set).sort((a, b) => b.localeCompare(a));
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredResults = $derived.by<SearchIndexEntry[]>(() => {
|
type SearchIndexEntry = {
|
||||||
if (!isFiltering || !searchIndex) return [];
|
slug: string;
|
||||||
const q = normalizedQuery;
|
headline: string;
|
||||||
return searchIndex
|
excerpt: string;
|
||||||
.filter((p) => {
|
subheadline: string;
|
||||||
if (year && yearOf(p) !== year) return false;
|
tags: string[];
|
||||||
if (q) {
|
image: string | null;
|
||||||
const hay = `${p.headline} ${p.excerpt} ${p.subheadline} ${p.tags.join(" ")}`.toLowerCase();
|
created: string | null;
|
||||||
if (!hay.includes(q)) return false;
|
isEvent: boolean;
|
||||||
|
eventDate: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type EventPost = PostEntry & { eventDate?: string; isEvent?: boolean };
|
||||||
|
|
||||||
|
let {
|
||||||
|
posts = [],
|
||||||
|
tags = [],
|
||||||
|
activeTag = null,
|
||||||
|
currentPage = 1,
|
||||||
|
totalPages = 1,
|
||||||
|
totalPosts = 0,
|
||||||
|
basePath = "/posts",
|
||||||
|
translations = {},
|
||||||
|
upcomingEvents = [],
|
||||||
|
searchIndex = null,
|
||||||
|
}: {
|
||||||
|
posts: PostEntry[];
|
||||||
|
tags: TagEntry[];
|
||||||
|
activeTag: string | null;
|
||||||
|
currentPage: number;
|
||||||
|
totalPages: number;
|
||||||
|
totalPosts?: number;
|
||||||
|
basePath?: string;
|
||||||
|
translations?: Translations | null;
|
||||||
|
upcomingEvents?: EventPost[];
|
||||||
|
searchIndex?: SearchIndexEntry[] | null;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let query = $state("");
|
||||||
|
let year = $state<string>("");
|
||||||
|
const normalizedQuery = $derived(query.trim().toLowerCase());
|
||||||
|
const isFiltering = $derived(normalizedQuery.length >= 2 || year !== "");
|
||||||
|
|
||||||
|
function yearOf(entry: SearchIndexEntry): string {
|
||||||
|
const iso = entry.created ?? "";
|
||||||
|
if (!iso) return "";
|
||||||
|
const d = new Date(iso);
|
||||||
|
return Number.isNaN(d.getTime()) ? "" : String(d.getFullYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
const availableYears = $derived.by<string[]>(() => {
|
||||||
|
if (!searchIndex) return [];
|
||||||
|
const set = new Set<string>();
|
||||||
|
for (const p of searchIndex) {
|
||||||
|
const y = yearOf(p);
|
||||||
|
if (y) set.add(y);
|
||||||
}
|
}
|
||||||
return true;
|
return Array.from(set).sort((a, b) => b.localeCompare(a));
|
||||||
})
|
});
|
||||||
.slice(0, 80);
|
|
||||||
});
|
|
||||||
|
|
||||||
function searchResultHref(slug: string): string {
|
const filteredResults = $derived.by<SearchIndexEntry[]>(() => {
|
||||||
const norm = (slug ?? "").replace(/^\//, "").trim();
|
if (!isFiltering || !searchIndex) return [];
|
||||||
return norm ? `/post/${encodeURIComponent(norm)}` : "/post";
|
const q = normalizedQuery;
|
||||||
}
|
return searchIndex
|
||||||
|
.filter((p) => {
|
||||||
|
if (year && yearOf(p) !== year) return false;
|
||||||
|
if (q) {
|
||||||
|
const hay =
|
||||||
|
`${p.headline} ${p.excerpt} ${p.subheadline} ${p.tags.join(" ")}`.toLowerCase();
|
||||||
|
if (!hay.includes(q)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.slice(0, 80);
|
||||||
|
});
|
||||||
|
|
||||||
function t(key: string, replacements?: Record<string, string | number>) {
|
function searchResultHref(slug: string): string {
|
||||||
return tStatic(translations ?? null, key, replacements);
|
const norm = (slug ?? "").replace(/^\//, "").trim();
|
||||||
}
|
return norm ? `/post/${encodeURIComponent(norm)}` : "/post";
|
||||||
|
}
|
||||||
|
|
||||||
function tagHref(tagSlug: string | null): string {
|
function t(key: string, replacements?: Record<string, string | number>) {
|
||||||
if (!tagSlug) return `${basePath}/`;
|
return tStatic(translations ?? null, key, replacements);
|
||||||
return `${basePath}/tag/${encodeURIComponent(tagSlug)}/`;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const totalCount = $derived(totalPosts);
|
function tagHref(tagSlug: string | null): string {
|
||||||
|
if (!tagSlug) return `${basePath}/`;
|
||||||
|
return `${basePath}/tag/${encodeURIComponent(tagSlug)}/`;
|
||||||
|
}
|
||||||
|
|
||||||
// Bulk-fetch comment counts for the visible posts (single request per render).
|
const totalCount = $derived(totalPosts);
|
||||||
let commentCounts = $state<CommentCountsMap>({});
|
|
||||||
$effect(() => {
|
// Bulk-fetch comment counts for the visible posts (single request per render).
|
||||||
const ctrl = new AbortController();
|
let commentCounts = $state<CommentCountsMap>({});
|
||||||
fetchCommentCounts(posts.map(postSlugForComments), { signal: ctrl.signal })
|
$effect(() => {
|
||||||
.then((map) => {
|
const ctrl = new AbortController();
|
||||||
commentCounts = map;
|
fetchCommentCounts(posts.map(postSlugForComments), {
|
||||||
});
|
signal: ctrl.signal,
|
||||||
return () => ctrl.abort();
|
}).then((map) => {
|
||||||
});
|
commentCounts = map;
|
||||||
|
});
|
||||||
|
return () => ctrl.abort();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="blog-overview">
|
<div class="blog-overview">
|
||||||
{#if searchIndex}
|
{#if searchIndex}
|
||||||
<div class="mb-4 flex flex-wrap items-center gap-2">
|
<div class="mb-4 flex flex-wrap items-center gap-2">
|
||||||
<label class="relative block w-full sm:max-w-sm">
|
<label class="relative block w-full sm:max-w-sm">
|
||||||
<span class="sr-only">{t(T.blog_search_label)}</span>
|
<span class="sr-only">{t(T.blog_search_label)}</span>
|
||||||
<span class="pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-zinc-500">
|
<span
|
||||||
<Icon icon="mdi:magnify" class="h-4 w-4" />
|
class="pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-zinc-500"
|
||||||
</span>
|
>
|
||||||
<input
|
<Icon icon="mdi:magnify" class="h-4 w-4" />
|
||||||
type="search"
|
</span>
|
||||||
bind:value={query}
|
<input
|
||||||
placeholder={t(T.blog_search_placeholder)}
|
type="search"
|
||||||
class="w-full rounded-sm border border-zinc-300 bg-white py-2 pr-9 pl-8 text-sm focus:border-zinc-500 focus:outline-none"
|
bind:value={query}
|
||||||
/>
|
placeholder={t(T.blog_search_placeholder)}
|
||||||
{#if query}
|
class="w-full rounded-sm border border-zinc-300 bg-white py-2 pr-9 pl-8 text-sm focus:border-zinc-500 focus:outline-none"
|
||||||
<button
|
/>
|
||||||
type="button"
|
{#if query}
|
||||||
onclick={() => (query = "")}
|
<button
|
||||||
class="absolute top-1/2 right-1.5 -translate-y-1/2 rounded-sm p-1 text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900"
|
type="button"
|
||||||
aria-label={t(T.blog_search_clear)}
|
onclick={() => (query = "")}
|
||||||
>
|
class="absolute top-1/2 right-1.5 -translate-y-1/2 rounded-sm p-1 text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900"
|
||||||
<Icon icon="mdi:close" class="h-4 w-4" />
|
aria-label={t(T.blog_search_clear)}
|
||||||
</button>
|
>
|
||||||
{/if}
|
<Icon icon="mdi:close" class="h-4 w-4" />
|
||||||
</label>
|
</button>
|
||||||
{#if availableYears.length > 0}
|
{/if}
|
||||||
<label class="relative inline-flex items-center">
|
</label>
|
||||||
<span class="sr-only">{t(T.blog_year_label)}</span>
|
{#if availableYears.length > 0}
|
||||||
<span class="pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-zinc-500">
|
<label class="relative inline-flex items-center">
|
||||||
<Icon icon="mdi:calendar" class="h-4 w-4" />
|
<span class="sr-only">{t(T.blog_year_label)}</span>
|
||||||
</span>
|
<span
|
||||||
<select
|
class="pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-zinc-500"
|
||||||
bind:value={year}
|
>
|
||||||
class="appearance-none rounded-sm border border-zinc-300 bg-white py-2 pr-7 pl-8 text-sm focus:border-zinc-500 focus:outline-none"
|
<Icon icon="mdi:calendar" class="h-4 w-4" />
|
||||||
>
|
</span>
|
||||||
<option value="">{t(T.blog_year_all)}</option>
|
<select
|
||||||
{#each availableYears as y}
|
bind:value={year}
|
||||||
<option value={y}>{y}</option>
|
class="appearance-none rounded-sm border border-zinc-300 bg-white py-2 pr-7 pl-8 text-sm focus:border-zinc-500 focus:outline-none"
|
||||||
{/each}
|
>
|
||||||
</select>
|
<option value="">{t(T.blog_year_all)}</option>
|
||||||
<span class="pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 text-zinc-500">
|
{#each availableYears as y}
|
||||||
<Icon icon="mdi:chevron-down" class="h-4 w-4" />
|
<option value={y}>{y}</option>
|
||||||
</span>
|
{/each}
|
||||||
</label>
|
</select>
|
||||||
{/if}
|
<span
|
||||||
</div>
|
class="pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 text-zinc-500"
|
||||||
{/if}
|
>
|
||||||
|
<Icon icon="mdi:chevron-down" class="h-4 w-4" />
|
||||||
{#if !isFiltering && upcomingEvents.length > 0}
|
</span>
|
||||||
<section class="not-prose mb-6 rounded-sm border border-zinc-200 bg-zinc-50 p-4">
|
</label>
|
||||||
<h2 class="mb-3 flex items-center gap-2 text-sm font-semibold tracking-wide text-zinc-700 uppercase">
|
|
||||||
<Icon icon="mdi:calendar-clock" class="size-5 shrink-0" />
|
|
||||||
{t(T.blog_upcoming_events)}
|
|
||||||
</h2>
|
|
||||||
<ul class="not-prose list-none space-y-2 pl-0">
|
|
||||||
{#each upcomingEvents as ev}
|
|
||||||
<li>
|
|
||||||
<a href={postHref(ev)} class="group flex flex-wrap items-center gap-2 no-underline hover:underline">
|
|
||||||
<EventBadges eventDate={ev.eventDate} />
|
|
||||||
<span class="text-sm text-zinc-900 group-hover:text-zinc-950">{ev.headline}</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if isFiltering}
|
|
||||||
<div class="mb-3 flex flex-wrap items-center gap-2 text-xs text-zinc-600">
|
|
||||||
<span>
|
|
||||||
{t(T.blog_results_count, { count: filteredResults.length })}
|
|
||||||
{#if query}{t(T.blog_results_for, { query })}{/if}
|
|
||||||
{#if year}{t(T.blog_results_in_year, { year })}{/if}
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onclick={() => { query = ""; year = ""; }}
|
|
||||||
class="text-zinc-500 underline hover:text-zinc-900"
|
|
||||||
>{t(T.blog_filter_reset)}</button>
|
|
||||||
</div>
|
|
||||||
{#if filteredResults.length > 0}
|
|
||||||
<div class="py-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
||||||
{#each filteredResults as hit}
|
|
||||||
<a href={searchResultHref(hit.slug)} class="flex flex-col overflow-hidden border border-gray-200 bg-white text-slate-950 no-underline transition-all">
|
|
||||||
{#if hit.image}
|
|
||||||
<div class="aspect-3/2 w-full overflow-hidden bg-gray-100">
|
|
||||||
<img src={hit.image} alt={hit.headline} class="h-full w-full object-cover" loading="lazy" />
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-1 flex-col p-4">
|
</div>
|
||||||
<h3 class="mb-1 text-base font-semibold">{hit.headline}</h3>
|
{/if}
|
||||||
{#if hit.excerpt}
|
|
||||||
<p class="text-sm text-zinc-700 line-clamp-3">{hit.excerpt}</p>
|
{#if !isFiltering && upcomingEvents.length > 0}
|
||||||
{/if}
|
<section
|
||||||
|
class="not-prose mb-6 rounded-sm border border-zinc-200 bg-zinc-50 p-4"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
class="mb-3 flex items-center gap-2 text-sm font-semibold tracking-wide text-zinc-700"
|
||||||
|
>
|
||||||
|
<Icon icon="mdi:calendar-clock" class="size-7 shrink-0" />
|
||||||
|
{t(T.blog_upcoming_events)}
|
||||||
|
</h2>
|
||||||
|
<ul class="not-prose list-none space-y-2 pl-0">
|
||||||
|
{#each upcomingEvents as ev}
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href={postHref(ev)}
|
||||||
|
class="group flex flex-wrap items-center gap-2 no-underline"
|
||||||
|
>
|
||||||
|
<EventBadges eventDate={ev.eventDate} />
|
||||||
|
<span
|
||||||
|
class="text-sm text-zinc-900 group-hover:text-zinc-950"
|
||||||
|
>{ev.headline}</span
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if isFiltering}
|
||||||
|
<div
|
||||||
|
class="mb-3 flex flex-wrap items-center gap-2 text-xs text-zinc-600"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{t(T.blog_results_count, { count: filteredResults.length })}
|
||||||
|
{#if query}{t(T.blog_results_for, { query })}{/if}
|
||||||
|
{#if year}{t(T.blog_results_in_year, { year })}{/if}
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={() => {
|
||||||
|
query = "";
|
||||||
|
year = "";
|
||||||
|
}}
|
||||||
|
class="text-zinc-500 underline hover:text-zinc-900"
|
||||||
|
>{t(T.blog_filter_reset)}</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{#if filteredResults.length > 0}
|
||||||
|
<div
|
||||||
|
class="py-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
|
||||||
|
>
|
||||||
|
{#each filteredResults as hit}
|
||||||
|
<a
|
||||||
|
href={searchResultHref(hit.slug)}
|
||||||
|
class="flex flex-col overflow-hidden border border-gray-200 bg-white text-slate-950 no-underline transition-all"
|
||||||
|
>
|
||||||
|
{#if hit.image}
|
||||||
|
<div
|
||||||
|
class="aspect-3/2 w-full overflow-hidden bg-gray-100"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={hit.image}
|
||||||
|
alt={hit.headline}
|
||||||
|
class="h-full w-full object-cover"
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div class="flex flex-1 flex-col p-4">
|
||||||
|
<h3 class="mb-1 text-base font-semibold">
|
||||||
|
{hit.headline}
|
||||||
|
</h3>
|
||||||
|
{#if hit.excerpt}
|
||||||
|
<p class="text-sm text-zinc-700 line-clamp-3">
|
||||||
|
{hit.excerpt}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
{:else}
|
||||||
{/each}
|
<div
|
||||||
</div>
|
class="rounded-sm border border-zinc-200 bg-white p-6 text-center text-sm text-zinc-600"
|
||||||
|
>
|
||||||
|
{t(T.blog_no_results)}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="rounded-sm border border-zinc-200 bg-white p-6 text-center text-sm text-zinc-600">
|
{#if tags.length > 0}
|
||||||
{t(T.blog_no_results)}
|
<div class="mb-2">
|
||||||
</div>
|
<div
|
||||||
{/if}
|
class="flex flex-wrap gap-2"
|
||||||
{:else}
|
role="navigation"
|
||||||
{#if tags.length > 0}
|
aria-label={t(T.blog_filter_aria)}
|
||||||
<div class="mb-2">
|
>
|
||||||
<div class="flex flex-wrap gap-2" role="navigation" aria-label={t(T.blog_filter_aria)}>
|
<Tag
|
||||||
<Tag
|
label={t(T.blog_tag_all)}
|
||||||
label={t(T.blog_tag_all)}
|
href={tagHref(null)}
|
||||||
href={tagHref(null)}
|
variant={activeTag ? "blue" : "green"}
|
||||||
variant={activeTag ? "blue" : "green"}
|
active={!activeTag}
|
||||||
active={!activeTag}
|
/>
|
||||||
/>
|
{#each tags as tag}
|
||||||
{#each tags as tag}
|
{@const slug = tag._slug ?? ""}
|
||||||
{@const slug = tag._slug ?? ""}
|
<Tag
|
||||||
<Tag
|
label={tag.name}
|
||||||
label={tag.name}
|
href={tagHref(slug)}
|
||||||
href={tagHref(slug)}
|
variant={activeTag === slug ? "inactive" : "green"}
|
||||||
variant={activeTag === slug ? "inactive" : "green"}
|
active={activeTag === slug}
|
||||||
active={activeTag === slug}
|
icon={tag.icon?.trim() || null}
|
||||||
icon={tag.icon?.trim() || null}
|
customColor={activeTag === slug
|
||||||
customColor={activeTag === slug ? null : tag.color?.trim() || null}
|
? null
|
||||||
/>
|
: tag.color?.trim() || null}
|
||||||
{/each}
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Pagination {currentPage} {totalPages} {basePath} {activeTag} />
|
||||||
|
|
||||||
|
<div class="py-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
|
{#each posts as post}
|
||||||
|
<PostCard
|
||||||
|
{post}
|
||||||
|
href={postHref(post)}
|
||||||
|
tagBase={`${basePath}/tag`}
|
||||||
|
commentCount={commentCounts[postSlugForComments(post)] ??
|
||||||
|
null}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Pagination
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
{currentPage}
|
<Pagination {currentPage} {totalPages} {basePath} {activeTag} />
|
||||||
{totalPages}
|
<div class="grow"></div>
|
||||||
{basePath}
|
<div class="bg-white rounded-md font-thin">
|
||||||
activeTag={activeTag}
|
<div class="inline-flex text-xs p-2">
|
||||||
/>
|
{#if totalCount > 0}
|
||||||
|
{t(T.blog_count, {
|
||||||
<div class="py-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
visible: posts.length,
|
||||||
{#each posts as post}
|
total: totalCount,
|
||||||
<PostCard
|
current: currentPage,
|
||||||
post={post}
|
totalPages,
|
||||||
href={postHref(post)}
|
})}
|
||||||
tagBase={`${basePath}/tag`}
|
{:else}
|
||||||
commentCount={commentCounts[postSlugForComments(post)] ?? null}
|
{t(T.blog_count, {
|
||||||
/>
|
visible: 0,
|
||||||
{/each}
|
total: 0,
|
||||||
</div>
|
current: currentPage,
|
||||||
|
totalPages,
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
})}
|
||||||
<Pagination
|
{/if}
|
||||||
{currentPage}
|
</div>
|
||||||
{totalPages}
|
</div>
|
||||||
{basePath}
|
|
||||||
activeTag={activeTag}
|
|
||||||
/>
|
|
||||||
<div class="grow"></div>
|
|
||||||
<div class="bg-white rounded-md font-thin">
|
|
||||||
<div class="inline-flex text-xs p-2">
|
|
||||||
{#if totalCount > 0}
|
|
||||||
{t(T.blog_count, {
|
|
||||||
visible: posts.length,
|
|
||||||
total: totalCount,
|
|
||||||
current: currentPage,
|
|
||||||
totalPages,
|
|
||||||
})}
|
|
||||||
{:else}
|
|
||||||
{t(T.blog_count, {
|
|
||||||
visible: 0,
|
|
||||||
total: 0,
|
|
||||||
current: currentPage,
|
|
||||||
totalPages,
|
|
||||||
})}
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-4 text-xs text-zinc-600">
|
<div class="mt-4 text-xs text-zinc-600">
|
||||||
<a href="/posts/rss.xml" class="inline-flex items-center gap-1 hover:underline">
|
<a
|
||||||
<Icon icon="mdi:rss" class="h-3.5 w-3.5" />
|
href="/posts/rss.xml"
|
||||||
{t(T.blog_rss_subscribe)}
|
class="inline-flex items-center gap-1 hover:underline"
|
||||||
</a>
|
>
|
||||||
</div>
|
<Icon icon="mdi:rss" class="h-3.5 w-3.5" />
|
||||||
{/if}
|
{t(T.blog_rss_subscribe)}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user