summaryrefslogtreecommitdiff
path: root/examples/hackernews/src/components/For.astro
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hackernews/src/components/For.astro')
-rw-r--r--examples/hackernews/src/components/For.astro21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/hackernews/src/components/For.astro b/examples/hackernews/src/components/For.astro
new file mode 100644
index 000000000..b784f8f8a
--- /dev/null
+++ b/examples/hackernews/src/components/For.astro
@@ -0,0 +1,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>