Sort by newest news & display human readable date
This commit is contained in:
parent
c7fb3f7945
commit
81ffeaa780
|
@ -5,6 +5,11 @@
|
||||||
export let title = '<title>';
|
export let title = '<title>';
|
||||||
export let summary = '<summary>';
|
export let summary = '<summary>';
|
||||||
export let creation_date = '<date>';
|
export let creation_date = '<date>';
|
||||||
|
|
||||||
|
const monthNames = ["January", "February", "March", "April", "May", "June",
|
||||||
|
"July", "August", "September", "October", "November", "December"];
|
||||||
|
|
||||||
|
$: human_creation_date = new Date(+creation_date * 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="news-card">
|
<div class="news-card">
|
||||||
|
@ -15,7 +20,7 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h3 id="title">{title}</h3>
|
<h3 id="title">{title}</h3>
|
||||||
<p id="summary-text">{summary}</p>
|
<p id="summary-text">{summary}</p>
|
||||||
<p id="date">{creation_date}</p>
|
<p id="date">{human_creation_date.getDate()} {monthNames[human_creation_date.getMonth()]} {human_creation_date.getFullYear()}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
export let title = '<title>';
|
export let title = '<title>';
|
||||||
export let summary = '<summary>';
|
export let summary = '<summary>';
|
||||||
export let creation_date = '<date>';
|
export let creation_date = '<date>';
|
||||||
|
|
||||||
|
const monthNames = ["January", "February", "March", "April", "May", "June",
|
||||||
|
"July", "August", "September", "October", "November", "December"];
|
||||||
|
|
||||||
|
$: human_creation_date = new Date(+creation_date * 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="news-card">
|
<div class="news-card">
|
||||||
|
@ -15,7 +20,7 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h3 id="title">{title}</h3>
|
<h3 id="title">{title}</h3>
|
||||||
<p id="summary-text">{summary}</p>
|
<p id="summary-text">{summary}</p>
|
||||||
<p id="date">{creation_date}</p>
|
<p id="date">{human_creation_date.getDate()} {monthNames[human_creation_date.getMonth()]} {human_creation_date.getFullYear()}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,9 @@ type Summary = {
|
||||||
export function load() {
|
export function load() {
|
||||||
let summaries : Summary[] = [];
|
let summaries : Summary[] = [];
|
||||||
|
|
||||||
|
// Sort by newest news first
|
||||||
|
posts.sort((a, b) => b.creation_date - a.creation_date);
|
||||||
|
|
||||||
posts.map((post) => {
|
posts.map((post) => {
|
||||||
let summary : Summary = {
|
let summary : Summary = {
|
||||||
url: post.url,
|
url: post.url,
|
||||||
|
|
Loading…
Reference in New Issue