diff options
author | 2022-11-01 16:20:04 +0000 | |
---|---|---|
committer | 2022-11-01 16:20:04 +0000 | |
commit | 4e2bd173932c231697a17a3098dc22ef3e481525 (patch) | |
tree | 0cf7877436a1463d78dad231ef28ebd8116225fc /examples/hackernews/src/components/For.astro | |
parent | bb6e8800094dc59841eb3b345fcb8baca9e17ce9 (diff) | |
download | astro-4e2bd173932c231697a17a3098dc22ef3e481525.tar.gz astro-4e2bd173932c231697a17a3098dc22ef3e481525.tar.zst astro-4e2bd173932c231697a17a3098dc22ef3e481525.zip |
Adds a Hackernews example site (#5213)
* adds the hackernews example - TODO add readme content
* refactor: moving styles from root.css into components
* chore: add README content
* chore: lint fixes + prettier-plugin-astro@0.4.0
* Update examples/hackernews/README.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* lint: remove unused variable
* nit: adding check command to example
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to 'examples/hackernews/src/components/For.astro')
-rw-r--r-- | examples/hackernews/src/components/For.astro | 21 |
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> |