diff --git a/src/components/LoadMore.astro b/src/components/LoadMore.astro index 3b0d16f..6efd5b3 100644 --- a/src/components/LoadMore.astro +++ b/src/components/LoadMore.astro @@ -13,10 +13,18 @@ const { limit, total, cls = 'grid3', label = 'Load more' } = Astro.props; const step = Number(box.dataset.limit) || 12; const items = [...box.querySelector('.lm-list')!.children] as HTMLElement[]; let shown = step; - const apply = () => items.forEach((el, i) => { el.hidden = i >= shown; }); - apply(); const btn = box.querySelector('.btn-load'); - btn?.addEventListener('click', () => { shown += step; apply(); if (shown >= items.length) btn.parentElement!.remove(); }); + // data-cat が付いた一覧は、選んだ種類(box.dataset.cat)のカードだけを数えて見せる + const apply = () => { + const cat = box.dataset.cat || ''; + const pool = items.filter((el) => !cat || el.dataset.cat === cat); + items.forEach((el) => { el.hidden = true; }); + pool.forEach((el, i) => { el.hidden = i >= shown; }); + if (btn) btn.parentElement!.hidden = shown >= pool.length; + }; + apply(); + btn?.addEventListener('click', () => { shown += step; apply(); }); + box.addEventListener('lm:filter', () => { shown = step; apply(); }); } diff --git a/src/components/MangaCard.astro b/src/components/MangaCard.astro index 31c2d41..171afc3 100644 --- a/src/components/MangaCard.astro +++ b/src/components/MangaCard.astro @@ -1,10 +1,10 @@ --- import { ymd } from '../lib/format'; import { media } from '../lib/media'; -interface Props { item: { slug: string; title: string; label: string; character: string; published: string; cover: string }; base?: string } -const { item, base = '/manga' } = Astro.props; +interface Props { item: { slug: string; title: string; label: string; character: string; published: string; cover: string }; base?: string; cat?: string } +const { item, base = '/manga', cat } = Astro.props; --- - + {item.title}
{item.label}{item.character}{ymd(item.published)}