cdrdpyj/src/pages/news/[id].astro

40 lines
1017 B
Plaintext

---
import "../../styles/global.css";
import { Image } from "@unpic/astro";
import { getCollection, render } from 'astro:content';
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const posts = await getCollection('news');
return posts.map(post => ({
params: { id: post.id },
props: { post },
}));
}
// 2. For your template, you can get the entry directly from the prop
const { post } = Astro.props;
const { Content } = await render(post);
---
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
<h1>{post.data.title}</h1>
<Image
src={post.data.thumbnail}
layout="constrained"
width={800}
height={600}
alt={post.data.title}
/>
<Content />
</body>
</html>