summaryrefslogtreecommitdiff
path: root/examples/hackernews/src/components/For.astro
blob: 885c22a65f08c1e64289c866ca70cb0e8c635ef7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
import Show from './Show.astro';

export interface Props<T> {
	each: Iterable<T>;
}

const { each } = Astro.props;
---

{
	(async function* () {
		for await (const value of each) {
			let html = await Astro.slots.render('default', [value]);
			yield <Fragment set:html={html} />;
			yield '\n';
		}
	})()
}

<Show when={!each.length}>
	<slot name="fallback" />
</Show>