From bd73d8decb482e05fc8e2d81ac369aae84d5865c Mon Sep 17 00:00:00 2001 From: Robin Cussol Date: Tue, 7 Apr 2020 14:17:25 +0200 Subject: [PATCH] fix(examples): implement CR's suggestions Refactored the function into a reactive declaration. Added similar reactive declaration in `Item.svelte` too. Note that the conditional is slightly different in each case: - in `Summary.svelte`, the API response gives correct type 'ask' for 'Ask HN'-type posts, - but in `Item.svelte`, a different API call resolves these 'Ask HN'-type posts with type 'link'. In both cases, however, 'item.domain' is undefined. --- .../21-miscellaneous/01-hacker-news/Item.svelte | 6 ++++-- .../21-miscellaneous/01-hacker-news/Summary.svelte | 12 +++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte b/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte index e9cd617e96..802ab437f7 100644 --- a/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte +++ b/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte @@ -3,6 +3,8 @@ export let item; export let returnTo; + + $: url = !item.domain ? `https://news.ycombinator.com/${item.url}` : item.url;