From 2029de45baf64b2394bb71aeef7e117994bca071 Mon Sep 17 00:00:00 2001 From: Robin Cussol Date: Mon, 6 Apr 2020 15:57:45 +0200 Subject: [PATCH] fix(examples): use correct URL for Ask HN posts Before, the link for items of type `ask` would be `https://svelte.dev/item?id=22792829` (which returns a 404), and with this change, the correct URL `https://news.ycombinator.com/item?id=22792829` is generated. --- .../21-miscellaneous/01-hacker-news/Summary.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/site/content/examples/21-miscellaneous/01-hacker-news/Summary.svelte b/site/content/examples/21-miscellaneous/01-hacker-news/Summary.svelte index 0ff25964f7..a5eb820da5 100644 --- a/site/content/examples/21-miscellaneous/01-hacker-news/Summary.svelte +++ b/site/content/examples/21-miscellaneous/01-hacker-news/Summary.svelte @@ -7,6 +7,14 @@ const c = item.comments_count; return `${c} ${c === 1 ? 'comment' : 'comments'}`; } + + function item_url() { + const { url, type } = item; + if (type === "ask") { + return `https://news.ycombinator.com/${url}`; + } + return url; + }