Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last updated to blog posts #1205

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/markdoc/layouts/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
export let timeToRead: string;
export let cover: string;
export let category: string;
export let lastUpdated: string;

const authors = getContext<AuthorData[]>('authors');
const authorData = authors.find((a) => a.slug === author);
Expand Down Expand Up @@ -231,6 +232,15 @@
{/if}

<div class="web-article-content u-margin-block-start-32">
{#if lastUpdated}
<span class="web-main-body-500 last-updated-text">
Updated:
<time dateTime={lastUpdated}>
{formatDate(lastUpdated)}
</time>
</span>
{/if}

<slot />
</div>
</article>
Expand Down Expand Up @@ -315,4 +325,8 @@
font-size: 24px;
}
}

.last-updated-text {
color: var(--primary, #e4e4e7);
}
</style>
1 change: 1 addition & 0 deletions src/routes/blog/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function load() {
description: frontmatter.description,
featured: frontmatter?.featured ?? false,
date: new Date(frontmatter.date),
lastUpdated: new Date(frontmatter.lastUpdated),
cover: frontmatter.cover,
timeToRead: frontmatter.timeToRead,
author: frontmatter.author,
Expand Down
2 changes: 2 additions & 0 deletions src/routes/blog/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type PostsData = {
title: string;
description: string;
date: Date;
lastUpdated: Date;
cover: string;
timeToRead: number;
author: string;
Expand Down Expand Up @@ -51,6 +52,7 @@ export const posts = Object.entries(postsGlob)
title: frontmatter.title,
description: frontmatter.description,
date: new Date(frontmatter.date),
lastUpdated: new Date(frontmatter.lastUpdated),
TorstenDittmann marked this conversation as resolved.
Show resolved Hide resolved
cover: frontmatter.cover,
timeToRead: frontmatter.timeToRead,
author: frontmatter.author,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: post
title: "Announcing: A new Init. Faster. Smoother. Better."
description: Init is about to begin, and we’re bringing you many new features and products to be excited about. Experience everything new with Appwrite during the week of August 19 to 23.
date: 2024-08-07
lastUpdated: 2024-08-10
cover: /images/blog/announcing-init-faster-smoother-better/init-cover.png
timeToRead: 4
author: eldad-fux
Expand Down
Loading