add updated date display to blog and project entries
This commit is contained in:
parent
b2b6db7b6d
commit
df67034454
|
|
@ -21,10 +21,10 @@ jobs:
|
||||||
- name: Checkout your repository using git
|
- name: Checkout your repository using git
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
- name: Install, build, and upload your site output
|
- name: Install, build, and upload your site output
|
||||||
uses: withastro/action@v5
|
uses: withastro/action@v6
|
||||||
with:
|
with:
|
||||||
# path: . # The root location of your Astro project inside the repository. (optional)
|
# path: . # The root location of your Astro project inside the repository. (optional)
|
||||||
# node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
|
# node-version: 24 # The specific version of Node that should be used to build your site. Defaults to 24. (optional)
|
||||||
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
|
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
onlyBuiltDependencies:
|
allowBuilds:
|
||||||
- esbuild
|
esbuild: true
|
||||||
- sharp
|
sharp: true
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@ export default function ArrowCard({ entry, pill }: Props) {
|
||||||
)}
|
)}
|
||||||
<div class="text-sm font-departure uppercase">
|
<div class="text-sm font-departure uppercase">
|
||||||
{formatDate(entry.data.date)}
|
{formatDate(entry.data.date)}
|
||||||
|
{entry.data.updated && (
|
||||||
|
<span class="text-xs text-black/50 dark:text-white/50 ml-1">
|
||||||
|
(updated {formatDate(entry.data.updated)})
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="font-semibold mt-3 text-black dark:text-white">
|
<div class="font-semibold mt-3 text-black dark:text-white">
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,24 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Blog({ data, tags }: Props) {
|
export default function Blog({ data, tags }: Props) {
|
||||||
|
function getDateOfLatestUpdate(entry: CollectionEntry<"blog">) {
|
||||||
|
return entry.data.updated ?? entry.data.date;
|
||||||
|
}
|
||||||
|
|
||||||
function filterPosts(): CollectionEntry<"blog">[] {
|
function filterPosts(): CollectionEntry<"blog">[] {
|
||||||
return data.filter((entry) =>
|
return data
|
||||||
|
.filter((entry) =>
|
||||||
Array.from(filter()).every((value) =>
|
Array.from(filter()).every((value) =>
|
||||||
entry.data.tags.some(
|
entry.data.tags.some(
|
||||||
(tag: string) =>
|
(tag: string) =>
|
||||||
tag.toLowerCase() === String(value).toLowerCase(),
|
tag.toLowerCase() === String(value).toLowerCase(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
.toSorted(
|
||||||
|
(a, b) =>
|
||||||
|
getDateOfLatestUpdate(b).getTime() -
|
||||||
|
getDateOfLatestUpdate(a).getTime(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,24 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Projects({ data, tags }: Props) {
|
export default function Projects({ data, tags }: Props) {
|
||||||
|
function getDateOfLatestUpdate(entry: CollectionEntry<"projects">) {
|
||||||
|
return entry.data.updated ?? entry.data.date;
|
||||||
|
}
|
||||||
|
|
||||||
function filterProjects(): CollectionEntry<"projects">[] {
|
function filterProjects(): CollectionEntry<"projects">[] {
|
||||||
return data.filter((entry) =>
|
return data
|
||||||
|
.filter((entry) =>
|
||||||
Array.from(filter()).every((value) =>
|
Array.from(filter()).every((value) =>
|
||||||
entry.data.tags.some(
|
entry.data.tags.some(
|
||||||
(tag: string) =>
|
(tag: string) =>
|
||||||
tag.toLowerCase() === String(value).toLowerCase(),
|
tag.toLowerCase() === String(value).toLowerCase(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
.toSorted(
|
||||||
|
(a, b) =>
|
||||||
|
getDateOfLatestUpdate(b).getTime() -
|
||||||
|
getDateOfLatestUpdate(a).getTime(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ const blog = defineCollection({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
summary: z.string(),
|
summary: z.string(),
|
||||||
date: z.date(),
|
date: z.date(),
|
||||||
|
updated: z.date().optional(),
|
||||||
tags: z.array(z.string()),
|
tags: z.array(z.string()),
|
||||||
draft: z.boolean().optional(),
|
draft: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
|
|
@ -42,6 +43,7 @@ const projects = defineCollection({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
summary: z.string(),
|
summary: z.string(),
|
||||||
date: z.date(),
|
date: z.date(),
|
||||||
|
updated: z.date().optional(),
|
||||||
tags: z.array(z.string()),
|
tags: z.array(z.string()),
|
||||||
draft: z.boolean().optional(),
|
draft: z.boolean().optional(),
|
||||||
demoUrl: z.string().optional(),
|
demoUrl: z.string().optional(),
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,17 @@ const repoUrl = collection === "projects" ? data.repoUrl : null;
|
||||||
<Icon name="pixelarticons:calendar-2" class:list="size-5" />
|
<Icon name="pixelarticons:calendar-2" class:list="size-5" />
|
||||||
{formatDate(date)}
|
{formatDate(date)}
|
||||||
</div>
|
</div>
|
||||||
|
{
|
||||||
|
entry.data.updated && (
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Icon
|
||||||
|
name="pixelarticons:calendar-range"
|
||||||
|
class:list="size-5"
|
||||||
|
/>
|
||||||
|
Updated {formatDate(entry.data.updated)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Icon name="pixelarticons:book-open" class:list="size-5" />
|
<Icon name="pixelarticons:book-open" class:list="size-5" />
|
||||||
{readingTime(body ?? "")}
|
{readingTime(body ?? "")}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue