0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
svelte/documentation/examples/21-miscellaneous/01-hacker-news/Item.svelte

44 lines
652 B
Svelte
Raw Normal View History

<script>
2023-05-14 07:50:43 +02:00
import Comment from './Comment.svelte';
export let item;
2019-04-15 15:10:17 +02:00
export let returnTo;
$: url = !item.domain ? `https://news.ycombinator.com/${item.url}` : item.url;
</script>
2019-04-15 15:10:17 +02:00
<a href={returnTo}>&laquo; back</a>
<article>
2023-05-14 07:50:43 +02:00
<a href={url}>
<h1>{item.title}</h1>
{#if item.domain}
<small>{item.domain}</small>
{/if}
</a>
2023-05-14 07:50:43 +02:00
<p class="meta">submitted by {item.user} {item.time_ago}</p>
</article>
<div class="comments">
{#each item.comments as comment}
2023-05-14 07:50:43 +02:00
<Comment {comment} />
{/each}
</div>
<style>
article {
margin: 0 0 1em 0;
}
a {
display: block;
margin: 0 0 1em 0;
}
h1 {
font-size: 1.4em;
margin: 0;
}
2023-05-14 07:50:43 +02:00
</style>