---
/**
* Responsive grid of link cards for Sources/Clients, with an icon (or initials avatar) per service.
* Icons are shared with the app from src/client/components/icons/custom.
*/
import FocusSiblings from './FocusSiblings.astro';
import { withBase } from '../withBase';
import type { Service } from '../data/services';
interface Props {
services: Service[];
label?: string;
}
const { services, label } = Astro.props;
const icons = import.meta.glob<{ default: any }>('../../../src/client/components/icons/custom/*.svg', { eager: true });
const getIcon = (name?: string) => (name === undefined ? undefined : icons[`../../../src/client/components/icons/custom/${name}.svg`]?.default);
// same as Chakra Avatar fallback: first letters of the first and last words
const initials = (name: string) => {
const words = name.split(' ');
return (words.length > 1 ? `${words[0][0]}${words[words.length - 1][0]}` : words[0][0]).toUpperCase();
};
---
{services.map((s) => {
const Icon = getIcon(s.icon);
return (
{Icon !== undefined ? : {initials(s.name)}}
{s.name}
{s.note && {s.note}}
);
})}