From a3e2be718d293724dc76be967a318d517d7d9ec1 Mon Sep 17 00:00:00 2001 From: "aitor c. urrutia aranburu" Date: Thu, 12 Nov 2026 12:26:19 +0100 Subject: [PATCH] feat: random post funtzionalitatea sartzen du --- src/components/HomePosts.astro | 3 +-- src/components/PostGrid.astro | 44 ++++++++++++++++++++++++++++++++++ src/pages/index.astro | 2 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/components/HomePosts.astro b/src/components/HomePosts.astro index 3e5b829..e2d8a9f 100644 --- a/src/components/HomePosts.astro +++ b/src/components/HomePosts.astro @@ -1,6 +1,5 @@ --- import type { CollectionEntry } from "astro:content"; -import Post from "../components/Post.astro"; import PostGrid from "./PostGrid.astro"; interface Props { @@ -17,7 +16,7 @@ let posts = allPosts new Date(b.data.updated || b.data.added).valueOf() - new Date(a.data.updated || a.data.added).valueOf(), ) - .slice(0, 8); + .slice(0, 7); --- diff --git a/src/components/PostGrid.astro b/src/components/PostGrid.astro index b665d99..6e557d7 100644 --- a/src/components/PostGrid.astro +++ b/src/components/PostGrid.astro @@ -7,6 +7,11 @@ interface Props { const { posts } = Astro.props; +const postSlugs = posts.reduce( + (slugs, { data: { slug } }) => [slug, ...slugs], + [], +); + function getTiltDegrees() { const degreeCollection = [0.5, 1, 1.5, 2]; const randomKey = Math.floor(Math.random() * degreeCollection.length); @@ -35,8 +40,32 @@ function getTiltDegrees() { )) } + +
  • + +
    + Bestela, irakurri ausaz aukeratutako post bat 🎲 +
  • + +