Skip to content

Commit 11673fe

Browse files
authored
Merge pull request #677 from datum-cloud/style/last-update
chore: lastupdate component handbook
2 parents 096a3ba + d97016c commit 11673fe

File tree

7 files changed

+75
-45
lines changed

7 files changed

+75
-45
lines changed

package-lock.json

Lines changed: 3 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/handbook/Article.astro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
// src/components/handbook/Article.astro
23
import { getCollection, getEntry, render } from 'astro:content';
34
import { Breadcrumbs } from 'astro-breadcrumbs';
45
import Sidebar from '@components/handbook/Sidebar.astro';
@@ -234,7 +235,12 @@ handbooks.forEach((collection) => {
234235
</div>
235236

236237
{/* Navigation */}
237-
<PageNav currentArticleId={articleId} categories={categories} items={items} />
238+
<PageNav
239+
currentArticleId={articleId}
240+
categories={categories}
241+
items={items}
242+
lastUpdated={mainArticleEntry?.data.lastUpdated}
243+
/>
238244
</article>
239245

240246
<aside class="handbook-toc">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
import { formatLongDate, formatISODate } from '@utils/dateUtils';
3+
4+
interface LastUpdatedProps {
5+
date?: Date;
6+
}
7+
8+
const { date } = Astro.props as LastUpdatedProps;
9+
10+
if (!date) {
11+
return null;
12+
}
13+
14+
const formattedDate = formatLongDate(date);
15+
const dateTime = formatISODate(date);
16+
---
17+
18+
{
19+
date && (
20+
<p class="last-updated">
21+
Last updated: <time datetime={dateTime}>{formattedDate}</time>
22+
</p>
23+
)
24+
}
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
2+
// src/components/handbook/PageNav.astro
23
import ArticleNavigation from '@components/ArticleNavigation.astro';
4+
import LastUpdated from '@components/handbook/LastUpdated.astro';
35
import type { SidebarItems } from '@/src/types/common';
46
57
const {
68
currentArticleId,
79
items,
10+
lastUpdated,
811
class: className,
912
} = Astro.props as {
1013
currentArticleId: string;
1114
class?: string;
1215
items: SidebarItems[];
16+
lastUpdated?: Date;
1317
};
1418
1519
const handbookItems: Array<{ id: string; data: { title: string } }> = [];
@@ -32,20 +36,25 @@ const nextArticle =
3236
currentIndex < handbookItems.length - 1 ? handbookItems[currentIndex + 1] : undefined;
3337
---
3438

35-
<ArticleNavigation
36-
previousArticle={previousArticle
37-
? {
38-
id: previousArticle.id,
39-
title: previousArticle.data.title,
40-
url: `/handbook/${previousArticle.id}/`,
41-
}
42-
: undefined}
43-
nextArticle={nextArticle
44-
? {
45-
id: nextArticle.id,
46-
title: nextArticle.data.title,
47-
url: `/handbook/${nextArticle.id}/`,
48-
}
49-
: undefined}
50-
class={className}
51-
/>
39+
{/* Last Updated */}
40+
<footer id="footer-article" class="article-footer">
41+
{lastUpdated && <LastUpdated date={lastUpdated} />}
42+
43+
<ArticleNavigation
44+
previousArticle={previousArticle
45+
? {
46+
id: previousArticle.id,
47+
title: previousArticle.data.title,
48+
url: `/handbook/${previousArticle.id}/`,
49+
}
50+
: undefined}
51+
nextArticle={nextArticle
52+
? {
53+
id: nextArticle.id,
54+
title: nextArticle.data.title,
55+
url: `/handbook/${nextArticle.id}/`,
56+
}
57+
: undefined}
58+
class={className}
59+
/>
60+
</footer>

src/content.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ const handbooks = defineCollection({
188188
draft: z.boolean().optional(),
189189
readingTime: z.string().optional(),
190190
updatedDate: z.string().optional(),
191+
lastUpdated: z.date().optional(),
191192
authors: z.string().optional(),
192193
sidebar: z.object({
193194
label: z.string().optional(),

src/content/handbook/policy/code-of-conduct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Code of conduct
3+
lastUpdated: 2025-12-04
34
sidebar:
45
label: Code of conduct
56
order: 1

src/v1/styles/components.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@
279279
@apply mt-10 flex flex-col gap-4 md:mt-14 md:flex-row;
280280
}
281281

282+
.article-footer {
283+
@apply mt-10 md:mt-14;
284+
@apply flex flex-col gap-6;
285+
.article-nav {
286+
@apply mt-0 md:mt-0;
287+
}
288+
289+
.last-updated {
290+
@apply datum-text-sm mb-0 text-right;
291+
@apply text-midnight-fjord;
292+
}
293+
}
294+
282295
.article-nav-item {
283296
@apply hover:text-midnight-fjord/80 text-midnight-fjord border-midnight-fjord hover:bg-midnight-fjord/5 hover:border-midnight-fjord/80;
284297
@apply w-full gap-2 border transition-colors duration-200;

0 commit comments

Comments
 (0)