feat: Adressbuch-Block mit Suche, Org- und Buchstabenfilter
- AdressbuchBlock: listet alle Kontakte alphabetisch mit Suche, Org-Filter-Chips und A–Z-Buchstabenfilter; /adressbuch-Seite - ContactCard: neues Design passend zu OrganisationsCard (Badges, Links) - ContactsBlock: Karussell mit snap-scroll, volle Breite - block-types, blog-utils, cms: AdressbuchBlockData, resolveAdressbuchBlocks, getContacts; BlockRenderer registriert adressbuch - Kontakt-Seite: Link auf /adressbuch statt eingebettetem Block Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
getEntryBySlug,
|
||||
getCalendarBySlug,
|
||||
getCalendarItemBySlug,
|
||||
getContacts,
|
||||
getCalendarItems,
|
||||
} from "./cms";
|
||||
import type { RowContentLayout } from "./block-types";
|
||||
@@ -833,3 +834,29 @@ export async function resolveStellingnahmeGeneratorBlocks(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function resolveAdressbuchBlocks(
|
||||
layout: RowContentLayout | null | undefined,
|
||||
): Promise<void> {
|
||||
if (!layout) return;
|
||||
const rows = [layout.row1Content ?? [], layout.row2Content ?? [], layout.row3Content ?? []];
|
||||
let contacts: unknown[] | null = null;
|
||||
for (const content of rows) {
|
||||
if (!Array.isArray(content)) continue;
|
||||
for (const item of content) {
|
||||
if (typeof item !== "object" || item === null) continue;
|
||||
if ((item as { _type?: string })._type !== "adressbuch") continue;
|
||||
if (contacts === null) contacts = await getContacts();
|
||||
const block = item as Record<string, unknown>;
|
||||
const exclude = (block.excludeContacts as unknown[]) ?? [];
|
||||
const excludeSlugs = new Set(
|
||||
exclude.map((e) =>
|
||||
typeof e === "string" ? e : (e as { _slug?: string })?._slug ?? ""
|
||||
).filter(Boolean)
|
||||
);
|
||||
block.resolvedContacts = excludeSlugs.size
|
||||
? contacts.filter((c) => !excludeSlugs.has((c as { _slug?: string })._slug ?? ""))
|
||||
: contacts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user