mirror of
https://github.com/Pantonius/pantosite-astro.git
synced 2026-04-26 17:34:39 +00:00
Very first version of pantosite-astro
This commit is contained in:
22
src/pages/projects/[...slug].astro
Normal file
22
src/pages/projects/[...slug].astro
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from 'astro:content';
|
||||
import BlogPost from '../../layouts/BlogPost.astro';
|
||||
import { render } from 'astro:content';
|
||||
import { convertCollectionPost, convertPost, type Post } from '../../models/Post';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts: Post[] = (await getCollection('projects')).map(convertPost);
|
||||
return posts.map((post) => ({
|
||||
params: { slug: post.id },
|
||||
props: post,
|
||||
}));
|
||||
}
|
||||
type Props = CollectionEntry<'projects'>;
|
||||
|
||||
const post: Post = Astro.props;
|
||||
const { Content } = await render(convertCollectionPost(post));
|
||||
---
|
||||
|
||||
<BlogPost {...post}>
|
||||
<Content />
|
||||
</BlogPost>
|
||||
31
src/pages/projects/index.astro
Normal file
31
src/pages/projects/index.astro
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
import BaseHead from '../../components/BaseHead.astro';
|
||||
import Header from '../../components/Header.astro';
|
||||
import Footer from '../../components/Footer.astro';
|
||||
import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts';
|
||||
import { getCollection } from 'astro:content';
|
||||
import Showcase from '../../components/Showcase.astro';
|
||||
import { convertPost } from '../../models/Post';
|
||||
|
||||
const posts: Post[] = (await getCollection('projects')).map(convertPost).sort(
|
||||
(a, b) => b.pubDate.valueOf() - a.pubDate.valueOf(),
|
||||
);
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
<main>
|
||||
{posts.length === 0 ? (
|
||||
<h1 style="opacity: .5; user-select: none;">No posts yet 😛</h1>
|
||||
) : (
|
||||
<Showcase collection="projects" posts={posts} />
|
||||
)}
|
||||
</main>
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user