chore: tipadoa konpontzen du

This commit is contained in:
txarli committed 2026-11-05 14:11:49 +01:00
1 parent a866661a82
commit 3b47191d78
6 files changed
+65 -58

No files matched your search

+6 -4
View File
@@ -1,6 +1,11 @@
--- ---
import type { CollectionEntry } from "astro:content";
import Post from "../components/Post.astro"; import Post from "../components/Post.astro";
interface Props {
allPosts: CollectionEntry<'posts'>[]
}
const { allPosts } = Astro.props; const { allPosts } = Astro.props;
//.sort(() => 0.5 - Math.random()).slice(0, 3); //.sort(() => 0.5 - Math.random()).slice(0, 3);
@@ -18,10 +23,7 @@ let posts = allPosts
<ul class="posts-list"> <ul class="posts-list">
{ {
posts.map( posts.map(
({ (post) => <Post post={post} />
url,
data: { description, slug, title, tags, added: date },
}) => <Post {url} {description} {date} {slug} {title} {tags} />
) )
} }
</ul> </ul>
+33 -23
View File
@@ -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;
--- ---
<li class="post"> <li class="post">
<a href={`/post/${slug}/`} class="title">{title}</a> <a href={`/post/${slug}/`} class="title">{title}</a>
<time datetime={date}> <time datetime={date as string}>
{ {
new Date(date).toLocaleDateString("eu", { new Date(date).toLocaleDateString("eu", {
year: "numeric", year: "numeric",
month: "short", month: "short",
day: "numeric", day: "numeric",
}) })
} }
</time> </time>
<br /> <br />
{description && <span class="excerpt">{description}</span>} {description && <span class="excerpt">{description}</span>}
<div> <div>
{ {
tags && tags &&
tags.map((tag: string) => ( tags.map((tag: string) => (
<a class="tag" href={`/tag/${tag}`}> <a class="tag" href={`/tag/${tag}`}>
#{tag} #{tag}
</a> </a>
)) ))
} }
</div> </div>
</li> </li>
+5
View File
@@ -1,4 +1,9 @@
--- ---
interface Props {
tags: string[];
all?: boolean;
}
const { tags, all } = Astro.props; const { tags, all } = Astro.props;
--- ---
+1 -1
View File
@@ -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"; import BlogPost from "../../layouts/BlogPost.astro";
export async function getStaticPaths() { export async function getStaticPaths() {
+16 -23
View File
@@ -11,32 +11,25 @@ import { SITE_TITLE, SITE_DESCRIPTION } from "../../config";
let posts = await getCollection("posts"); let posts = await getCollection("posts");
posts = posts.sort( posts = posts.sort(
(a, b) => (a, b) =>
new Date(b.data.updated || b.data.added).valueOf() - new Date(b.data.updated || b.data.added).valueOf() -
new Date(a.data.updated || a.data.added).valueOf(), new Date(a.data.updated || a.data.added).valueOf(),
); );
--- ---
<!doctype html> <!doctype html>
<html lang="eu"> <html lang="eu">
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} /> <BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
<body> <body>
<Header /> <Header />
<main> <main>
<content> <content>
<ul class="posts-list"> <ul class="posts-list">
{ {posts.map((post) => <Post post={post} />)}
posts.map( </ul>
({ </content>
url, </main>
data: { description, slug, title, tags, added: date }, <Footer />
}) => <Post {description} {date} {slug} {title} {tags} /> <ColorScript />
) </body>
}
</ul>
</content>
</main>
<Footer />
<ColorScript />
</body>
</html> </html>
+4 -7
View File
@@ -1,5 +1,5 @@
--- ---
import { getCollection } from "astro:content"; import { getCollection, type CollectionEntry } from "astro:content";
import BaseHead from "../../components/BaseHead.astro"; import BaseHead from "../../components/BaseHead.astro";
import Header from "../../components/Header.astro"; import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro"; import Footer from "../../components/Footer.astro";
@@ -9,8 +9,8 @@ import ColorScript from "../../components/ColorScript.astro";
import { SITE_TITLE, SITE_DESCRIPTION } from "../../config"; import { SITE_TITLE, SITE_DESCRIPTION } from "../../config";
export async function getStaticPaths() { export async function getStaticPaths() {
let posts = await getCollection("posts"); const posts = await getCollection("posts");
const tags = posts.reduce((allTags, post) => { const tags = posts.reduce<Record<string, CollectionEntry<"posts">[]>>((allTags, post) => {
const postTags = post.data.tags; const postTags = post.data.tags;
if (postTags) { if (postTags) {
postTags.forEach((tag) => { postTags.forEach((tag) => {
@@ -50,10 +50,7 @@ let sortedPosts = tag.sort(
<ul class="tags-list"> <ul class="tags-list">
{ {
sortedPosts.map( sortedPosts.map(
({ (post) => <Post post={post} />
url,
data: { description, slug, title, tags, added: date },
}) => <Post {url} {description} {date} {slug} {title} {tags} />
) )
} }
</ul> </ul>