From c7264e3ace8a6b1e22420702f00296a4bdadb6da Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 2 Feb 2024 23:25:31 -0500 Subject: Tags; More changes on blog --- src/pages/blog/[...slug].astro | 2 +- src/pages/blog/index.astro | 34 ++++++---------------------------- src/pages/blog/tags/[tag].astro | 25 +++++++++++++++---------- src/pages/index.astro | 13 ++++++++++++- src/pages/rss.xml.js | 2 +- 5 files changed, 35 insertions(+), 41 deletions(-) (limited to 'src/pages') diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 1eccb0b..e0b07e9 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -16,7 +16,7 @@ if(entry === undefined) { const { Content } = await entry.render(); --- - +
← All articles
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index f782cdc..74f543a 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -2,8 +2,9 @@ import Page from "../../layouts/Page.astro"; import { getCollection } from "astro:content"; import {formatDate} from "../../util"; +import "../../styles/cards.css"; -const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()); +const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); ---
@@ -11,10 +12,12 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.date.va {allBlogPosts.map((post) => (

{post.data.title}

- {formatDate(post.data.date)} + {formatDate(post.data.pubDate)}

{post.data.description}

- tag1 + {post.data.tags.map((tag) => ( + {tag} + ))}
)) @@ -23,34 +26,9 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.date.va
diff --git a/src/pages/blog/tags/[tag].astro b/src/pages/blog/tags/[tag].astro index a43f13f..9d4ff86 100644 --- a/src/pages/blog/tags/[tag].astro +++ b/src/pages/blog/tags/[tag].astro @@ -1,6 +1,8 @@ --- import Page from '../../../layouts/Page.astro'; - +import {formatDate} from "../../../util"; +import "../../../styles/cards.css"; +export const prerender = true; export async function getStaticPaths() { const allPosts = await Astro.glob('../../../content/blog/*.md'); let uniqueTags = []; @@ -21,13 +23,16 @@ export async function getStaticPaths() { const { tag } = Astro.params; const { posts } = Astro.props; --- - - {console.log(posts)} - {posts && posts.map((post) => { - return ( - - ) - })} + +
+ {posts && posts.map((post) => { + return ( + + ) + })} +
diff --git a/src/pages/index.astro b/src/pages/index.astro index 0918a74..35ed847 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -2,8 +2,13 @@ import Layout from '../layouts/Default.astro'; import { Icon } from 'astro-icon/components' import { Image } from 'astro:assets'; +import { getCollection } from "astro:content"; + import Profile from '../images/Alee.png'; import '../styles/index.css'; +import {formatDate} from "../util"; +const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()).slice(0, 10); + --- @@ -73,7 +78,13 @@ import '../styles/index.css';

Latest Posts

-

Hello world

+ {allBlogPosts.map((post) => ( + + ))}
diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index df0645d..fe17f91 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -18,7 +18,7 @@ export async function GET(context) { // See "Generating items" section for examples using content collections and glob imports items: blog.map((post) => ({ title: post.data.title, - pubDate: post.data.date, + pubDate: post.data.pubDate, description: post.data.description, // Compute RSS link from post `slug` // This example assumes all posts are rendered as `/blog/[slug]` routes -- cgit v1.2.3