feat: some shit
This commit is contained in:
5
src/pages/about/index.astro
Normal file
5
src/pages/about/index.astro
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
|
||||
<Layout title="Home"> Sup people :) </Layout>
|
26
src/pages/api/blog/[slug].json.ts
Normal file
26
src/pages/api/blog/[slug].json.ts
Normal 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
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
39
src/pages/blog/[slug].astro
Normal file
39
src/pages/blog/[slug].astro
Normal 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>
|
30
src/pages/blog/index.astro
Normal file
30
src/pages/blog/index.astro
Normal 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
13
src/pages/index.astro
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
|
||||
|
||||
---
|
||||
|
||||
<Layout title="dude">
|
||||
|
||||
# Das ist mein Blog
|
||||
|
||||
</Layout>
|
||||
|
||||
|
Reference in New Issue
Block a user