feat: add some stuff
This commit is contained in:
37
src/pages/projects/[slug].astro
Normal file
37
src/pages/projects/[slug].astro
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import Post from "@layouts/Post.astro";
|
||||
import { getLocale } from "astro-i18n-aut";
|
||||
import { filterCollection, parseSlug } from "@i18n/utils";
|
||||
|
||||
const locale = getLocale(Astro.url);
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const pages = await getCollection("projects");
|
||||
|
||||
const paths = pages.map((page) => {
|
||||
const [slug] = parseSlug(page.id);
|
||||
return { params: { slug }, props: { ...page } };
|
||||
});
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
const pages = await getCollection("projects");
|
||||
const page = filterCollection(pages, locale).find((page) => {
|
||||
const [slug] = parseSlug(page.id);
|
||||
return slug === Astro.params.slug;
|
||||
});
|
||||
|
||||
if (!page) {
|
||||
return new Response("Not found", {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
|
||||
const { Content } = await page.render();
|
||||
---
|
||||
|
||||
<Post {...page.data} backlink="/projects">
|
||||
<Content />
|
||||
</Post>
|
25
src/pages/projects/index.astro
Normal file
25
src/pages/projects/index.astro
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import { getLocale } from "astro-i18n-aut";
|
||||
import { filterCollection } from "@i18n/utils";
|
||||
|
||||
const locale = getLocale(Astro.url);
|
||||
const pages = await getCollection("projects");
|
||||
const posts = filterCollection(pages, locale);
|
||||
---
|
||||
|
||||
<Layout title="Dude">
|
||||
<hr />
|
||||
{
|
||||
posts.map((post) => (
|
||||
<>
|
||||
<>
|
||||
<a href={"projects/" + post.slug.split("/")[0]}>{post.data.title}</a>
|
||||
<br />
|
||||
</>
|
||||
</>
|
||||
))
|
||||
}
|
||||
<hr />
|
||||
</Layout>
|
Reference in New Issue
Block a user