summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/index.astro32
-rw-r--r--src/pages/micro/[...slug].astro34
-rw-r--r--src/pages/posts/[...page].astro6
-rw-r--r--src/pages/rss.xml.ts1
-rw-r--r--src/pages/tags/[tag]/[...page].astro44
-rw-r--r--src/pages/tags/[tag]/rss.xml.ts52
-rw-r--r--src/pages/tags/index.astro25
7 files changed, 59 insertions, 135 deletions
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 1bc088c..e3884ef 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,23 +1,27 @@
---
-import { type CollectionEntry, getCollection } from "astro:content";
+import type { CollectionEntry } from "astro:content";
import PostPreview from "@/components/blog/PostPreview.astro";
-import Note from "@/components/note/Note.astro";
import SocialList from "@/components/SocialList.astro";
import { getAllPosts } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
import { collectionDateSort } from "@/utils/date";
-// Posts
-const MAX_POSTS = 10;
+// Get all posts
const allPosts = await getAllPosts();
-const allPostsByDate = allPosts
+
+// Posts section - exclude archived and microblog
+const MAX_POSTS = 10;
+const regularPosts = allPosts.filter(
+ (post) => !post.data.tags.includes("archived") && !post.data.tags.includes("microblog"),
+);
+const allPostsByDate = regularPosts
.sort(collectionDateSort)
.slice(0, MAX_POSTS) as CollectionEntry<"post">[];
-// Micro
-const MAX_MICRO = 5;
-const allMicro = await getCollection("micro").catch(() => []); // Fallback to empty array if micro collection fails
-const latestMicro = allMicro.sort(collectionDateSort).slice(0, MAX_MICRO);
+// Microblog posts section - only posts with microblog tag
+const MAX_MICROBLOG = 5;
+const allMicroblogPosts = allPosts.filter((post) => post.data.tags.includes("microblog"));
+const latestMicroblog = allMicroblogPosts.sort(collectionDateSort).slice(0, MAX_MICROBLOG);
---
<PageLayout meta={{ title: "Home" }}>
@@ -46,15 +50,15 @@ const latestMicro = allMicro.sort(collectionDateSort).slice(0, MAX_MICRO);
</ul>
</section>
{
- latestMicro.length > 0 && (
+ latestMicroblog.length > 0 && (
<section class="mt-16">
<h2 class="title text-accent mb-6 text-xl">
- <a href="/tags/micro/">Micro</a>
+ <a href="/tags/microblog/">Microblog</a>
</h2>
<ul class="space-y-6" role="list">
- {latestMicro.map((note) => (
- <li>
- <Note note={note} as="h3" isPreview />
+ {latestMicroblog.map((post) => (
+ <li class="grid gap-2 sm:grid-cols-[auto_1fr]">
+ <PostPreview post={post} as="h3" />
</li>
))}
</ul>
diff --git a/src/pages/micro/[...slug].astro b/src/pages/micro/[...slug].astro
deleted file mode 100644
index 681c106..0000000
--- a/src/pages/micro/[...slug].astro
+++ /dev/null
@@ -1,34 +0,0 @@
----
-import { getCollection } from "astro:content";
-import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
-import Note from "@/components/note/Note.astro";
-import PageLayout from "@/layouts/Base.astro";
-import { siteConfig } from "@/site.config";
-
-// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
-export const getStaticPaths = (async () => {
- // Get only Pleroma posts
- const allMicro = await getCollection("micro").catch(() => []); // Fallback to empty array if micro collection fails
-
- return allMicro.map((post) => ({
- params: { slug: post.id },
- props: { note: post }, // Keep 'note' name for compatibility with existing component
- }));
-}) satisfies GetStaticPaths;
-
-export type Props = InferGetStaticPropsType<typeof getStaticPaths>;
-
-const { note } = Astro.props;
-
-const meta = {
- description:
- note.data.description ||
- `Read about my note posted on: ${note.data.publishDate.toLocaleDateString()}`,
- title: note.data.title,
- lang: note.data.language || siteConfig.lang,
-};
----
-
-<PageLayout meta={meta}>
- <Note as="h1" note={note} />
-</PageLayout>
diff --git a/src/pages/posts/[...page].astro b/src/pages/posts/[...page].astro
index acca040..d318525 100644
--- a/src/pages/posts/[...page].astro
+++ b/src/pages/posts/[...page].astro
@@ -12,7 +12,11 @@ export const getStaticPaths = (async ({ paginate }) => {
const MAX_POSTS_PER_PAGE = 10;
const MAX_TAGS = 7;
const allPosts = await getAllPosts();
- const sortedPosts = allPosts.sort(collectionDateSort);
+ // Filter out archived and microblog posts from main posts page
+ const filteredPosts = allPosts.filter(
+ (post) => !post.data.tags.includes("archived") && !post.data.tags.includes("microblog"),
+ );
+ const sortedPosts = filteredPosts.sort(collectionDateSort);
const uniqueTags = getUniqueTags(sortedPosts).slice(0, MAX_TAGS);
return paginate(sortedPosts, {
pageSize: MAX_POSTS_PER_PAGE,
diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts
index 39f3964..d428cc9 100644
--- a/src/pages/rss.xml.ts
+++ b/src/pages/rss.xml.ts
@@ -15,6 +15,7 @@ export const GET = async (context: APIContext) => {
description: post.data.description,
pubDate: post.data.publishDate,
link: `posts/${post.id}/`,
+ author: post.data.author,
})),
customData: `<atom:link href="${context.site}rss.xml" rel="self" type="application/rss+xml" xmlns:atom="http://www.w3.org/2005/Atom" />`,
});
diff --git a/src/pages/tags/[tag]/[...page].astro b/src/pages/tags/[tag]/[...page].astro
index 9556309..8ae9716 100644
--- a/src/pages/tags/[tag]/[...page].astro
+++ b/src/pages/tags/[tag]/[...page].astro
@@ -1,35 +1,27 @@
---
-import { getCollection, render } from "astro:content";
+import { render } from "astro:content";
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
import { Icon } from "astro-icon/components";
import PostPreview from "@/components/blog/PostPreview.astro";
-import Note from "@/components/note/Note.astro";
import Pagination from "@/components/Paginator.astro";
import { getAllPosts, getTagMeta, getUniqueTags } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
import { collectionDateSort } from "@/utils/date";
-import { getUniqueMicroTags } from "@/utils/micro";
export const getStaticPaths = (async ({ paginate }) => {
- const allPosts = await getAllPosts(true, true); // Include archived and micro posts for tag filtering
- const allMicro = await getCollection("micro", ({ data }) => data.tags?.includes("micro")).catch(
- () => [],
- );
+ const allPosts = await getAllPosts(true); // Include archived posts (now includes pleroma too)
- // Get unique tags from both collections
- const postTags = getUniqueTags(allPosts);
- const microTags = getUniqueMicroTags(allMicro);
- const allTags = [...new Set([...postTags, ...microTags])];
+ // Get unique tags from all posts
+ const allTags = getUniqueTags(allPosts);
return allTags.flatMap((tag) => {
- // Filter posts and micro posts by tag
+ // Filter posts by tag
const postsWithTag = allPosts.filter((post) => post.data.tags.includes(tag));
- const microWithTag = allMicro.filter((micro) => micro.data.tags?.includes(tag));
- // Combine and sort chronologically
- const allItems = [...postsWithTag, ...microWithTag].sort(collectionDateSort);
+ // Sort chronologically
+ const sortedPosts = postsWithTag.sort(collectionDateSort);
- return paginate(allItems, {
+ return paginate(sortedPosts, {
pageSize: 10,
params: { tag },
});
@@ -55,13 +47,13 @@ const meta = {
const paginationProps = {
...(page.url.prev && {
prevUrl: {
- text: "← Previous Tags",
+ text: "← Previous posts",
url: page.url.prev,
},
}),
...(page.url.next && {
nextUrl: {
- text: "Next Tags →",
+ text: "Next posts →",
url: page.url.next,
},
}),
@@ -96,17 +88,11 @@ const paginationProps = {
</div>
<ul class="space-y-6">
{
- page.data.map((item) =>
- item.collection === "post" ? (
- <li class="grid gap-2 sm:grid-cols-[auto_1fr]">
- <PostPreview as="h2" post={item} />
- </li>
- ) : (
- <li>
- <Note note={item} as="h2" isPreview />
- </li>
- ),
- )
+ page.data.map((post) => (
+ <li class="grid gap-2 sm:grid-cols-[auto_1fr]">
+ <PostPreview as="h2" post={post} />
+ </li>
+ ))
}
</ul>
<Pagination {...paginationProps} />
diff --git a/src/pages/tags/[tag]/rss.xml.ts b/src/pages/tags/[tag]/rss.xml.ts
index 3fc8ff3..3a61414 100644
--- a/src/pages/tags/[tag]/rss.xml.ts
+++ b/src/pages/tags/[tag]/rss.xml.ts
@@ -1,21 +1,14 @@
-import { getCollection } from "astro:content";
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getAllPosts, getUniqueTags } from "@/data/post";
import { siteConfig } from "@/site.config";
-import { getUniqueMicroTags } from "@/utils/micro";
export async function getStaticPaths() {
- // Get all posts (including archived) and micro posts to extract all possible tags
- const allPosts = await getAllPosts(true, true); // Include archived and micro
- const allMicro = await getCollection("micro", ({ data }) => data.tags?.includes("micro")).catch(
- () => [],
- );
+ // Get all posts (including archived, now includes pleroma too)
+ const allPosts = await getAllPosts(true);
- // Get unique tags from both collections
- const postTags = getUniqueTags(allPosts);
- const microTags = getUniqueMicroTags(allMicro);
- const allTags = [...new Set([...postTags, ...microTags])];
+ // Get unique tags from all posts
+ const allTags = getUniqueTags(allPosts);
return allTags.map((tag) => ({
params: { tag },
@@ -29,33 +22,14 @@ export const GET = async (context: APIContext) => {
throw new Error("Tag parameter is required");
}
- // Get posts with this tag (include archived and micro)
- const allPosts = await getAllPosts(true, true);
+ // Get posts with this tag (include archived)
+ const allPosts = await getAllPosts(true);
const postsWithTag = allPosts.filter((post) => post.data.tags.includes(tag));
- // Get micro posts with this tag
- const allMicro = await getCollection("micro", ({ data }) => data.tags?.includes("micro")).catch(
- () => [],
+ // Sort chronologically
+ const sortedPosts = postsWithTag.sort(
+ (a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(),
);
- const microWithTag = allMicro.filter((micro) => micro.data.tags?.includes(tag));
-
- // Combine and sort chronologically
- const allItems = [
- ...postsWithTag.map((post) => ({
- title: post.data.title,
- description: post.data.description,
- pubDate: post.data.publishDate,
- link: `posts/${post.id}/`,
- content: undefined,
- })),
- ...microWithTag.map((micro) => ({
- title: micro.data.title,
- description: micro.data.description,
- pubDate: micro.data.publishDate,
- link: `micro/${micro.id}/`,
- content: micro.rendered?.html || micro.body || "",
- })),
- ].sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime());
const site = context.site || import.meta.env.SITE;
@@ -63,7 +37,13 @@ export const GET = async (context: APIContext) => {
title: `${siteConfig.title} - ${tag}`,
description: `Posts tagged with ${tag}`,
site,
- items: allItems,
+ items: sortedPosts.map((post) => ({
+ title: post.data.title,
+ description: post.data.description,
+ pubDate: post.data.publishDate,
+ link: `posts/${post.id}/`,
+ author: post.data.author,
+ })),
customData: `<atom:link href="${site}tags/${tag}/rss.xml" rel="self" type="application/rss+xml" xmlns:atom="http://www.w3.org/2005/Atom" />`,
});
};
diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro
index 2c7b07b..260a4fa 100644
--- a/src/pages/tags/index.astro
+++ b/src/pages/tags/index.astro
@@ -1,29 +1,12 @@
---
-import { getCollection } from "astro:content";
import { getAllPosts, getUniqueTagsWithCount } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
-import { getUniqueMicroTagsWithCount } from "@/utils/micro";
-const allPostsIncludingArchived = await getAllPosts(true, true); // Include archived and micro
-const allMicro = await getCollection("micro", ({ data }) => data.tags?.includes("micro")).catch(
- () => [],
-);
+// Get all posts including archived (now includes pleroma posts too)
+const allPostsIncludingArchived = await getAllPosts(true);
-// Get tags with counts from both collections
-const postTags = getUniqueTagsWithCount(allPostsIncludingArchived);
-const microTags = getUniqueMicroTagsWithCount(allMicro);
-
-// Merge tags and sum counts
-const tagMap = new Map<string, number>();
-for (const [tag, count] of postTags) {
- tagMap.set(tag, count);
-}
-for (const [tag, count] of microTags) {
- tagMap.set(tag, (tagMap.get(tag) || 0) + count);
-}
-
-// Convert back to array and sort by count
-const allTags = Array.from(tagMap.entries()).sort((a, b) => b[1] - a[1]);
+// Get tags with counts from all posts
+const allTags = getUniqueTagsWithCount(allPostsIncludingArchived);
const meta = {
description: "A list of all the topics I've written about in my posts",