feat: some shit

This commit is contained in:
2024-03-26 16:36:18 +01:00
commit f0129ecc76
31 changed files with 5074 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
import Layout from "../../layouts/Layout.astro";
---
<Layout title="Home"> Sup people :) </Layout>

View File

@ -0,0 +1,26 @@
import { getCollection } from 'astro:content';
export async function GET({ params }: { params: { slug: string } }) {
const pages = await getCollection('blog');
return new Response(
JSON.stringify(pages.filter(post => {
return post.id.includes(params.slug)
})
))
}
export async function getStaticPaths() {
const pages = await getCollection('blog');
return pages.map(p => {
const [postId] = p.id.split('/');
return {
params: {
slug: postId
}
}
});
}

View File

@ -0,0 +1,39 @@
---
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("blog");
const paths = pages.map((page) => {
const [slug] = parseSlug(page.id);
return { params: { slug }, props: {...page} };
});
console.log("PATHS");
console.log(paths);
return paths;
}
const pages = await getCollection("blog");
const page = filterCollection(pages, locale).find((page) => {
const [slug] = parseSlug(page.id);
return slug === Astro.params.slug;
});
const formattedDate = page.data?.date?.toLocaleString(locale);
const { Content } = await page.render();
---
{locale}
{JSON.stringify(Astro.params)}
<Post {...page.data}>
<p>by {page.data.author} • {formattedDate}</p>
<Content />
</Post>

View File

@ -0,0 +1,30 @@
---
import { getCollection } from 'astro:content';
const pages = await getCollection('blog');
import Layout from '../../layouts/Layout.astro';
import { getLocale } from "astro-i18n-aut";
import { filterCollection } from '../../i18n/utils';
const locale = getLocale(Astro.url);
const posts = filterCollection(pages, locale);
console.log({posts, locale});
---
<Layout title="Dude">
<hr/>
{
posts.map((post) => (
<>
<a href={"blog/"+post.slug.split("/")[0]}>
{post.data.title}
</a><br/>
</>
))
}
<hr/>
</Layout>

13
src/pages/index.astro Normal file
View File

@ -0,0 +1,13 @@
---
import Layout from '../layouts/Layout.astro';
---
<Layout title="dude">
# Das ist mein Blog
</Layout>