aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2024-02-02 23:25:31 -0500
committerAndrew Lee <alee14498@protonmail.com>2024-02-02 23:30:29 -0500
commitc7264e3ace8a6b1e22420702f00296a4bdadb6da (patch)
tree1a157a968bea7e24fc708a22e933e8ea7ce01f1f /src/pages/blog
parent2c2bdccd645cafd26318c2f2659242f046b61daf (diff)
downloadpersonal-website-c7264e3ace8a6b1e22420702f00296a4bdadb6da.tar.gz
personal-website-c7264e3ace8a6b1e22420702f00296a4bdadb6da.tar.bz2
personal-website-c7264e3ace8a6b1e22420702f00296a4bdadb6da.zip
Tags; More changes on blog
Diffstat (limited to 'src/pages/blog')
-rw-r--r--src/pages/blog/[...slug].astro2
-rw-r--r--src/pages/blog/index.astro34
-rw-r--r--src/pages/blog/tags/[tag].astro25
3 files changed, 22 insertions, 39 deletions
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();
---
-<Page title={entry.data.title} description={entry.data.description} date={formatDate(entry.data.date)}>
+<Page title={entry.data.title} description={entry.data.description} pubDate={formatDate(entry.data.pubDate)}>
<main>
<a href="/blog" class="back-link">← All articles</a>
<article>
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());
---
<Page title="Blog" description="Where I post can be anything!">
<main>
@@ -11,10 +12,12 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.date.va
{allBlogPosts.map((post) => (
<article>
<h1><a href={`/blog/${post.slug}`}>{post.data.title}</a></h1>
- <small>{formatDate(post.data.date)}</small>
+ <small>{formatDate(post.data.pubDate)}</small>
<p>{post.data.description}</p>
<div class="tags">
- <a href={`/blog/${post.slug}`}>tag1</a>
+ {post.data.tags.map((tag) => (
+ <a href={`/blog/tags/${tag}`}>{tag}</a>
+ ))}
</div>
</article>
))
@@ -23,34 +26,9 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.date.va
</main>
</Page>
<style>
- h1 {
- margin-top: 2px;
- margin-bottom: 2px;
- }
-
.tags {
display: flex;
flex-direction: row;
gap: 1em;
}
-
- article {
- background-color: #3B513B;
- padding: 1.2em;
- border-radius: 20px;
- gap: 0.5em;
- margin: 0.5em;
- }
-
- main {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- }
-
- /* Mobile view */
- @media (max-width: 992px) {
- main {
- grid-template-columns: 1fr;
- }
- }
</style>
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;
---
-<Page title={tag}>
- {console.log(posts)}
- {posts && posts.map((post) => {
- return (
- <div>
- <a href={post.url}>{post.frontmatter.title}</a>
- </div>
- )
- })}
+<Page title=`Posts with ${tag}`>
+ <main>
+ {posts && posts.map((post) => {
+ return (
+ <article>
+ <h1><a href=`/blog/${post.frontmatter.slug}`>{post.frontmatter.title}</a></h1>
+ <small>{formatDate(post.frontmatter.pubDate)}</small>
+ <p>{post.frontmatter.description}</p>
+ </article>
+ )
+ })}
+ </main>
</Page>