80 lines
1.9 KiB
Svelte
80 lines
1.9 KiB
Svelte
<script lang="ts">
|
|
export let post_url : string = '404';
|
|
export let thumbnail_url : string = '/favicon.png';
|
|
export let thumbnail_alt : string = 'Picture describting the deprived devs logo';
|
|
export let title : string = '<title>';
|
|
export let summary : string = '<summary>';
|
|
export let creation_date : string = '<date>';
|
|
|
|
const monthNames : string[] = ["January", "February", "March", "April", "May", "June",
|
|
"July", "August", "September", "October", "November", "December"];
|
|
|
|
$: human_creation_date = new Date(+creation_date * 1000);
|
|
</script>
|
|
|
|
<div class="news-card">
|
|
<a href={post_url}>
|
|
<div class="thumbnail">
|
|
<img src={thumbnail_url} alt={thumbnail_alt}/>
|
|
</div>
|
|
<div class="content">
|
|
<p id="date">
|
|
{human_creation_date.getDate()}
|
|
{monthNames[human_creation_date.getMonth()]}
|
|
{human_creation_date.getFullYear()}
|
|
</p>
|
|
<h3 id="title">{title}</h3>
|
|
<p id="summary-text">{summary}</p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<style>
|
|
.news-card {
|
|
flex: 0 0 300px;
|
|
}
|
|
|
|
a {
|
|
min-width: 100%;
|
|
text-decoration: none;
|
|
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.thumbnail > img {
|
|
object-fit: cover;
|
|
|
|
box-shadow: 5px 5px 10px 2px rgba(0, 0, 0, 0.5);
|
|
border-radius: 8px;
|
|
|
|
min-width: 100%;
|
|
aspect-ratio: 16 / 9;
|
|
}
|
|
|
|
.content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
#title {
|
|
font-size: 22px;
|
|
margin: 0;
|
|
text-decoration: none;
|
|
color: var(--text2);
|
|
}
|
|
|
|
#summary-text {
|
|
margin: 0;
|
|
text-decoration: none;
|
|
color: var(--text3);
|
|
}
|
|
|
|
#date {
|
|
margin: 0;
|
|
text-decoration: none;
|
|
color: var(--text4);
|
|
}
|
|
</style>
|