summaryrefslogtreecommitdiff
path: root/examples/hackernews/src/components/For.astro
blob: 6eae88e27783b9b17c749c8fccd24b9d44bac4bb (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';

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>