summaryrefslogtreecommitdiff
path: root/examples/hackernews/src/components/For.astro
blob: b784f8f8a39eec189e008bb1e7cc0db41d39fb95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---
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>