fix(examples): use correct URL for Ask HN posts (#4640)

pull/4685/head
Robin Cussol 5 years ago committed by GitHub
parent d7497deaec
commit df3ae85b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,8 @@
export let item; export let item;
export let returnTo; export let returnTo;
$: url = !item.domain ? `https://news.ycombinator.com/${item.url}` : item.url;
</script> </script>
<style> <style>
@ -24,7 +26,7 @@
<a href={returnTo}>&laquo; back</a> <a href={returnTo}>&laquo; back</a>
<article> <article>
<a href="{item.url}"> <a href="{url}">
<h1>{item.title}</h1> <h1>{item.title}</h1>
<small>{item.domain}</small> <small>{item.domain}</small>
</a> </a>

@ -7,6 +7,8 @@
const c = item.comments_count; const c = item.comments_count;
return `${c} ${c === 1 ? 'comment' : 'comments'}`; return `${c} ${c === 1 ? 'comment' : 'comments'}`;
} }
$: url = item.type === "ask" ? `https://news.ycombinator.com/${item.url}` : item.url;
</script> </script>
<style> <style>
@ -33,6 +35,6 @@
<article> <article>
<span>{i + offset + 1}</span> <span>{i + offset + 1}</span>
<h2><a target="_blank" href={item.url}>{item.title}</a></h2> <h2><a target="_blank" href={url}>{item.title}</a></h2>
<p class="meta"><a href="#/item/{item.id}">{comment_text()}</a> by {item.user} {item.time_ago}</p> <p class="meta"><a href="#/item/{item.id}">{comment_text()}</a> by {item.user} {item.time_ago}</p>
</article> </article>
Loading…
Cancel
Save