Skip to content

Commit 158aba6

Browse files
committed
feat: improved date handling
1 parent 285cd37 commit 158aba6

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

site/src/components/Note.astro

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import markdownit from 'markdown-it';
33
4-
const { item } = Astro.props;
4+
const { item, hideDate } = Astro.props;
55
66
const md: markdownit = markdownit({
77
highlight: (str: string, lang: string) => {
@@ -35,7 +35,13 @@ const getFormattedDate = (date: string) => {
3535
<a href={`#${item.id}`} target="_blank">
3636
<h3 id={item.id}>{item.title}</h3>
3737
</a>
38-
<p class="note-list-item--time">{getFormattedDate(item.date_created)}</p>
38+
{
39+
!hideDate && (
40+
<p class="note-list-item--time">
41+
{getFormattedDate(item.date_created)}
42+
</p>
43+
)
44+
}
3945
<p set:html={md.render(item.text)} />
4046
<hr />
4147
</article>

site/src/components/NoteList.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import { fetchNotes } from '../functions/notes.func';
33
import Note from './Note.astro';
44
5-
var { filter } = Astro.props;
5+
var { filter, hideDate } = Astro.props;
66
77
const items = await fetchNotes(filter);
88
---
99

1010
{items.length === 0? <p>No notes found with this tag.</p>
1111
: (
1212
<ol class="note-list">
13-
{items.map((item: any) => <Note item={item} />)}
13+
{items.map((item: any) => <Note item={item} hideDate={hideDate} />)}
1414
</ol>
1515
)
1616
}

site/src/layouts/NotesPage.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Layout from './Layout.astro';
66
77
import rssIcon from '../resources/rss.svg';
88
9-
var { title, current } = Astro.props;
9+
var { title, current, hideDate } = Astro.props;
1010
---
1111

1212
<Layout title={title}>
@@ -27,7 +27,7 @@ var { title, current } = Astro.props;
2727
<FilterButtons current={current} />
2828
<slot />
2929
<ol class="note-list">
30-
<NoteList filter={current} />
30+
<NoteList filter={current} hideDate={hideDate} />
3131
</ol>
3232
</main>
3333
</Layout>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import NotesLayout from '../../layouts/NotesPage.astro';
33
---
4-
<NotesLayout title="Aaron Czichon - Notes - 365 Pictures" current="365pictures">
4+
<NotesLayout title="Aaron Czichon - Notes - 365 Pictures" current="365pictures" hideDate="true">
55
<p>This year, 2025, I try something new. Also to decouple myself a bit more from social media. This pages contains one picture of every day this year.</p>
66
</NotesLayout>

0 commit comments

Comments
 (0)