feat: some shit
This commit is contained in:
@ -19,8 +19,8 @@ const projects = filterCollection(
|
||||
getLocale(Astro.url),
|
||||
);
|
||||
|
||||
const t = useTranslations(Astro);
|
||||
const tp = useTranslatedPath(Astro);
|
||||
const t = useTranslations(Astro.url);
|
||||
const tp = useTranslatedPath(Astro.url);
|
||||
|
||||
const featuredProject = projects.find((project) => project.data?.featured);
|
||||
const otherProjects = projects
|
||||
|
@ -8,7 +8,7 @@ import HeroCard from "@components/HeroCard.astro";
|
||||
const locale = getLocale(Astro.url);
|
||||
const pages = await getCollection("projects");
|
||||
const posts = filterCollection(pages, locale)
|
||||
.sort((a, b) => b.data.date - a.data.date)
|
||||
.sort((a, b) => (b.data.date > a.data.date ? 1 : -1))
|
||||
.sort((a) => (a.data.featured ? -1 : 1));
|
||||
---
|
||||
|
||||
|
@ -3,28 +3,24 @@ import Layout from "@layouts/Layout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import { useTranslatedPath } from "@i18n/utils";
|
||||
|
||||
const collections = ["blog", "photos", "projects"];
|
||||
const collections = ["blog", "photos", "projects"] as const;
|
||||
|
||||
const tp = useTranslatedPath(Astro);
|
||||
const tp = useTranslatedPath(Astro.url);
|
||||
|
||||
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 collections = ["blog", "photos", "projects"] as const;
|
||||
const posts = await Promise.all(
|
||||
collections.map((collection) => getCollection(collection)),
|
||||
);
|
||||
|
||||
const tags = new Set();
|
||||
|
||||
posts.flat().forEach((post) => {
|
||||
if (!post.data?.tags) return;
|
||||
post.data.tags.forEach((tag: string) => {
|
||||
tags.add(tag.toLowerCase());
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
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 {
|
||||
@ -37,22 +33,17 @@ posts.flat().forEach((post) => {
|
||||
|
||||
const { tag } = Astro.params;
|
||||
|
||||
|
||||
const allPosts = (await Promise.all(
|
||||
collections.map((collection) => {
|
||||
return getCollection(collection, {
|
||||
fields: ["slug", "title", "date", "tags"],
|
||||
});
|
||||
}),
|
||||
)).flat();
|
||||
|
||||
|
||||
const allPosts = (
|
||||
await Promise.all(
|
||||
collections.map((collection) => {
|
||||
return getCollection(collection);
|
||||
}),
|
||||
)
|
||||
).flat();
|
||||
|
||||
const posts = allPosts.filter((post) => {
|
||||
return post.data?.tags?.find(t => t.toLowerCase() === tag);
|
||||
return post.data?.tags?.find((t) => t.toLowerCase() === tag);
|
||||
});
|
||||
|
||||
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
@ -62,10 +53,13 @@ const posts = allPosts.filter((post) => {
|
||||
<div class="flex flex-col gap-2">
|
||||
{
|
||||
posts.map((post) => {
|
||||
return <a href={tp("/"+post.collection+"/" + post.slug)}>{post.slug}</a>;
|
||||
return (
|
||||
<a href={tp("/" + post.collection + "/" + post.slug)}>
|
||||
{post.slug}
|
||||
</a>
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</article>
|
||||
</Layout>
|
||||
|
||||
|
@ -3,15 +3,13 @@ import Layout from "@layouts/Layout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import { useTranslatedPath } from "@i18n/utils";
|
||||
|
||||
const tp = useTranslatedPath(Astro);
|
||||
const tp = useTranslatedPath(Astro.url);
|
||||
|
||||
const collections = ["blog", "photos", "projects"];
|
||||
const collections = ["blog", "photos", "projects"] as const;
|
||||
|
||||
const posts = await Promise.all(
|
||||
collections.map((collection) => {
|
||||
return getCollection(collection, {
|
||||
fields: ["slug", "title", "date", "tags"],
|
||||
});
|
||||
return getCollection(collection);
|
||||
}),
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user