2023-08-31 03:47:22 +00:00
|
|
|
---
|
2023-08-31 08:07:03 +00:00
|
|
|
import "../../styles/post.scss";
|
2023-08-31 03:47:22 +00:00
|
|
|
import BaseLayout from "../../layouts/BaseLayout.astro";
|
|
|
|
import { type CollectionEntry, getCollection } from "astro:content";
|
2023-08-31 08:07:03 +00:00
|
|
|
import Timestamp from "../../components/Timestamp.astro";
|
2023-08-31 15:33:14 +00:00
|
|
|
import { getImage } from "astro:assets";
|
2023-08-31 03:47:22 +00:00
|
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
|
|
const posts = await getCollection("posts");
|
|
|
|
return posts.map((post) => ({
|
|
|
|
params: { slug: post.slug },
|
|
|
|
props: post,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
type Props = CollectionEntry<"posts">;
|
|
|
|
|
|
|
|
const post = Astro.props;
|
2023-08-31 08:07:03 +00:00
|
|
|
const { Content, remarkPluginFrontmatter } = await post.render();
|
2023-08-31 15:33:14 +00:00
|
|
|
const { heroImage: heroImagePath, heroAlt } = post.data;
|
|
|
|
|
|
|
|
let heroImage;
|
|
|
|
if (heroImagePath) {
|
|
|
|
heroImage = await getImage({ src: heroImagePath });
|
|
|
|
}
|
2023-08-31 15:37:26 +00:00
|
|
|
const datestamp = post.data.date.toLocaleDateString(undefined, {
|
|
|
|
year: "numeric",
|
|
|
|
month: "short",
|
|
|
|
day: "numeric",
|
|
|
|
});
|
2023-08-31 03:47:22 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
<BaseLayout>
|
2023-08-31 15:37:26 +00:00
|
|
|
<meta slot="head" property="og:title" content={post.data.title} />
|
2023-09-01 12:59:21 +00:00
|
|
|
<meta slot="head" property="og:url" content={Astro.url} />
|
|
|
|
<meta slot="head" property="og:description" content={remarkPluginFrontmatter.excerpt} />
|
2023-08-31 15:37:26 +00:00
|
|
|
<meta slot="head" property="og:type" content="article" />
|
2023-09-01 12:59:21 +00:00
|
|
|
<meta slot="head" property="og:locale" content="en_US" />
|
2023-09-01 03:45:24 +00:00
|
|
|
{heroImage && <meta slot="head" property="og:image" content={heroImage.src} />}
|
2023-09-01 12:59:21 +00:00
|
|
|
{heroAlt && <meta slot="head" property="og:image:alt" content={heroAlt} />}
|
|
|
|
|
2023-09-01 13:01:19 +00:00
|
|
|
<meta slot="head" property="keywords" content={post.data.tags.join(", ")} />
|
2023-09-01 12:59:21 +00:00
|
|
|
<meta slot="head" property="description" content={remarkPluginFrontmatter.excerpt} />
|
2023-08-31 15:37:26 +00:00
|
|
|
<meta slot="head" property="article:published_time" content={datestamp} />
|
2023-09-01 13:02:15 +00:00
|
|
|
<meta slot="head" property="article:author" content="Michael Zhang" />
|
2023-08-31 15:37:26 +00:00
|
|
|
|
2023-08-31 15:33:14 +00:00
|
|
|
<div class="post-container">
|
|
|
|
<h1 class="post-title">{post.data.title}</h1>
|
|
|
|
|
|
|
|
<small class="post-meta">
|
|
|
|
Posted on <Timestamp timestamp={post.data.date} />
|
|
|
|
- {remarkPluginFrontmatter.minutesRead}
|
|
|
|
</small>
|
2023-08-31 08:07:03 +00:00
|
|
|
|
2023-08-31 15:33:14 +00:00
|
|
|
{
|
|
|
|
heroImage && heroAlt && (
|
|
|
|
<div style={`background-image: url(${heroImage.src});`} title={heroAlt} class="hero" />
|
|
|
|
)
|
|
|
|
}
|
2023-08-31 08:07:03 +00:00
|
|
|
|
2023-08-31 15:33:14 +00:00
|
|
|
<!-- <BlogPost {...post.data}> -->
|
|
|
|
<div class="post-content">
|
|
|
|
<Content />
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-31 03:47:22 +00:00
|
|
|
<!-- </BlogPost> -->
|
|
|
|
</BaseLayout>
|