feat: add ci

This commit is contained in:
2024-04-03 16:18:30 +02:00
parent 93baa3b6b0
commit e800314589
13 changed files with 280 additions and 29 deletions

View File

@ -7,7 +7,9 @@ import HeroCard from "@components/HeroCard.astro";
const locale = getLocale(Astro.url);
const pages = await getCollection("projects");
const posts = filterCollection(pages, locale);
const posts = filterCollection(pages, locale)
.sort((a, b) => b.data.date - a.data.date)
.sort((a) => (a.data.featured ? -1 : 1));
---
<Layout title="Dude">

71
src/pages/tag/[tag].astro Normal file
View File

@ -0,0 +1,71 @@
---
import Layout from "@layouts/Layout.astro";
import { getCollection } from "astro:content";
import { useTranslatedPath } from "@i18n/utils";
const collections = ["blog", "photos", "projects"];
const tp = useTranslatedPath(Astro);
export async function getStaticPaths() {
const collections = ["blog", "photos", "projects"];
const posts = await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
});
}),
);
const tags = new Set();
posts.flat().forEach((post) => {
if (!post.data?.tags) return;
post.data.tags.forEach((tag) => {
tags.add(tag.toLowerCase());
});
});
return [...tags.values()].map((tag) => {
return {
params: {
tag,
},
};
});
}
const { tag } = Astro.params;
const allPosts = (await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
});
}),
)).flat();
const posts = allPosts.filter((post) => {
return post.data?.tags?.find(t => t.toLowerCase() === tag);
});
---
<Layout title="Max Richter">
<article>
<h1>Tags</h1>
{posts.length}
<div class="flex flex-col gap-2">
{
posts.map((post) => {
return <a href={tp("/"+post.collection+"/" + post.slug)}>{post.slug}</a>;
})
}
</div>
</article>
</Layout>

41
src/pages/tag/index.astro Normal file
View File

@ -0,0 +1,41 @@
---
import Layout from "@layouts/Layout.astro";
import { getCollection } from "astro:content";
import { useTranslatedPath } from "@i18n/utils";
const tp = useTranslatedPath(Astro);
const collections = ["blog", "photos", "projects"];
const posts = await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
});
}),
);
const tags = new Set();
posts.flat().forEach((post) => {
if (!post.data?.tags) return;
post.data.tags.forEach((tag) => {
tags.add(tag.toLowerCase());
});
});
const _tags = [...tags.values()];
---
<Layout title="Max Richter">
<article>
<h1>Tags</h1>
<div class="flex flex-col gap-2">
{
_tags.map((t) => {
return <a href={tp("/tag/" + t)}>{t}</a>;
})
}
</div>
</article>
</Layout>