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.
pull/4640/head
Robin Cussol 6 years ago committed by GitHub
parent d7497deaec
commit 2029de45ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}
</script>
<style>
@ -33,6 +41,6 @@
<article>
<span>{i + offset + 1}</span>
<h2><a target="_blank" href={item.url}>{item.title}</a></h2>
<h2><a target="_blank" href={item_url()}>{item.title}</a></h2>
<p class="meta"><a href="#/item/{item.id}">{comment_text()}</a> by {item.user} {item.time_ago}</p>
</article>
</article>

Loading…
Cancel
Save