diff --git a/src/components/HomePosts.astro b/src/components/HomePosts.astro index cd9b76a..1f687bc 100644 --- a/src/components/HomePosts.astro +++ b/src/components/HomePosts.astro @@ -1,6 +1,11 @@ --- +import type { CollectionEntry } from "astro:content"; import Post from "../components/Post.astro"; +interface Props { + allPosts: CollectionEntry<'posts'>[] +} + const { allPosts } = Astro.props; //.sort(() => 0.5 - Math.random()).slice(0, 3); @@ -18,10 +23,7 @@ let posts = allPosts diff --git a/src/components/Post.astro b/src/components/Post.astro index e3e9fb3..753b0d4 100644 --- a/src/components/Post.astro +++ b/src/components/Post.astro @@ -1,28 +1,38 @@ --- -const { slug, title, tags, description, date } = Astro.props; +import type { CollectionEntry } from "astro:content"; + +interface Props { + post: CollectionEntry<"posts">; +} + +const { + post: { + data: { slug, title, tags, description, added: date }, + }, +}: Props = Astro.props; ---
  • - {title} - -
    - {description && {description}} -
    - { - tags && - tags.map((tag: string) => ( - - #{tag} - - )) - } -
    + {title} + +
    + {description && {description}} +
    + { + tags && + tags.map((tag: string) => ( + + #{tag} + + )) + } +
  • diff --git a/src/components/Tags.astro b/src/components/Tags.astro index cb78deb..1d046cd 100644 --- a/src/components/Tags.astro +++ b/src/components/Tags.astro @@ -1,4 +1,9 @@ --- +interface Props { + tags: string[]; + all?: boolean; +} + const { tags, all } = Astro.props; --- diff --git a/src/pages/post/[slug].astro b/src/pages/post/[slug].astro index ca088d5..f9be4cd 100644 --- a/src/pages/post/[slug].astro +++ b/src/pages/post/[slug].astro @@ -1,5 +1,5 @@ --- -import { CollectionEntry, getCollection, render } from "astro:content"; +import { type CollectionEntry, getCollection, render } from "astro:content"; import BlogPost from "../../layouts/BlogPost.astro"; export async function getStaticPaths() { diff --git a/src/pages/post/index.astro b/src/pages/post/index.astro index 4df37b4..c1b4bcf 100644 --- a/src/pages/post/index.astro +++ b/src/pages/post/index.astro @@ -11,32 +11,25 @@ import { SITE_TITLE, SITE_DESCRIPTION } from "../../config"; let posts = await getCollection("posts"); posts = posts.sort( - (a, b) => - new Date(b.data.updated || b.data.added).valueOf() - - new Date(a.data.updated || a.data.added).valueOf(), + (a, b) => + new Date(b.data.updated || b.data.added).valueOf() - + new Date(a.data.updated || a.data.added).valueOf(), ); --- - - -
    -
    - -
      - { - posts.map( - ({ - url, - data: { description, slug, title, tags, added: date }, - }) => - ) - } -
    -
    -
    -