First post

This commit is contained in:
2025-01-13 23:01:22 +00:00
parent d0aa75a554
commit bee5f87d61
34 changed files with 1549 additions and 13951 deletions

View File

@@ -8,6 +8,7 @@ import type { CollectionEntry } from "astro:content";
import { slugifyStr } from "@utils/slugify";
import ShareLinks from "@components/ShareLinks.astro";
import { SITE } from "@config";
import {render} from 'astro:content'
export interface Props {
post: CollectionEntry<"blog">;
@@ -28,7 +29,7 @@ const {
editPost,
} = post.data;
const { Content } = await post.render();
const { Content } = await render(post)
const ogImageUrl = typeof ogImage === "string" ? ogImage : ogImage?.src;
const ogUrl = new URL(
@@ -49,12 +50,12 @@ const layoutProps = {
/* ========== Prev/Next Posts ========== */
const allPosts = posts.map(({ data: { title }, slug }) => ({
slug,
const allPosts = posts.map(({ data: { title }, id }) => ({
id,
title,
}));
const currentPostIndex = allPosts.findIndex(a => a.slug === post.slug);
const currentPostIndex = allPosts.findIndex(a => a.id === post.id);
const prevPost = currentPostIndex !== 0 ? allPosts[currentPostIndex - 1] : null;
const nextPost =
@@ -119,7 +120,7 @@ const nextPost =
{
prevPost && (
<a
href={`/posts/${prevPost.slug}`}
href={`/posts/${prevPost.id}`}
class="flex w-full gap-1 hover:opacity-75"
>
<svg
@@ -149,7 +150,7 @@ const nextPost =
{
nextPost && (
<a
href={`/posts/${nextPost.slug}`}
href={`/posts/${nextPost.id}`}
class="flex w-full justify-end gap-1 text-right hover:opacity-75 sm:col-start-2"
>
<div>