Skip to content

Commit e731030

Browse files
committed
Renamed colors and blog by year
1 parent 367ba6d commit e731030

File tree

6 files changed

+53
-34
lines changed

6 files changed

+53
-34
lines changed

src/common

src/content.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ const blog = defineCollection({
2525
const page = defineCollection({
2626
loader: glob({ pattern: '**/*.md', base: './src/content/page' }),
2727
schema: ({ image }) =>
28-
z.object({
29-
title: z.string(),
30-
description: z.string().optional(),
31-
pubDate: z.date().optional(),
28+
rssSchema.extend({
3229
coverImage: image().optional(),
3330
socialImage: image().optional(),
3431
images: z.array(image()).optional(),
Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,55 @@
11
---
2-
import type { Page, PaginateFunction } from 'astro'
32
import type { CollectionEntry } from 'astro:content'
4-
import { PAGE_SIZE, getPosts } from '../../common/config'
3+
import { getPosts } from '../../common/config'
54
import Base from '../../common/base.astro'
65
import PageHero from '../../common/pagehero.astro'
76
import BlogRoll from '../../common/blogroll.astro'
8-
import PaginateControl from '../../common/paginatecontrol.astro'
7+
import Years from '../../common/years.astro'
98
import coverImage from '../../images/svg/undraw/my_feed.svg'
109
import socialImage from '../../images/undraw/my_feed.png'
1110
1211
export interface Props {
13-
page: Page<CollectionEntry<'blog'>>
12+
year: number
13+
years: number[]
14+
posts: CollectionEntry<'blog'>[]
1415
}
1516
16-
const { page } = Astro.props
17+
const { year, years, posts } = Astro.props
1718
1819
const frontmatter: CollectionEntry<'page'>['data'] = {
19-
title:
20-
'Blog' +
21-
(page.size < page.total ? ' (page ' + page.currentPage + ' of ' + page.lastPage + ')' : ''),
22-
description: 'Articles I write from time to time',
20+
title: 'What happened in ' + year,
21+
description: 'These are some of the things I did and articles I have written in ' + year,
2322
coverImage: coverImage,
2423
socialImage: socialImage
2524
}
2625
27-
const currentPage = Astro.url.pathname.replace(/(\/\d*)?\/?$/, '')
28-
export async function getStaticPaths({ paginate }: { paginate: PaginateFunction }) {
26+
export async function getStaticPaths() {
2927
const posts = await getPosts()
28+
const years = [...new Set(posts.map((post) => new Date(post.data.pubDate!).getFullYear()))]
3029
31-
return paginate(posts, { pageSize: PAGE_SIZE })
30+
return years.map((year) => ({
31+
params: { year },
32+
props: {
33+
year,
34+
years,
35+
posts: posts.filter((post) => new Date(post.data.pubDate!).getFullYear() === +year)
36+
}
37+
}))
3238
}
3339
---
3440

3541
<Base frontmatter={frontmatter}>
3642
<header>
3743
<PageHero
38-
title={frontmatter.title}
44+
title={frontmatter.title!}
3945
description={frontmatter.description}
4046
coverImage={frontmatter.coverImage}
4147
socialImage={frontmatter.socialImage}
4248
>
43-
<PaginateControl base={currentPage} page={page} />
49+
<Years year={year} years={years} />
4450
</PageHero>
4551
</header>
4652
<main class='bg-rosely7 dark:bg-rosely1'>
47-
<BlogRoll posts={page.data} />
53+
<BlogRoll posts={posts} />
4854
</main>
4955
</Base>

src/pages/blog/index.astro

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
import { getPosts } from '../../common/config'
3+
4+
const posts = await getPosts()
5+
---
6+
7+
<!doctype html>
8+
<html>
9+
<head>
10+
<meta
11+
http-equiv='refresh'
12+
content={`0; url=${import.meta.env.BASE_URL + 'blog/' + posts[0].data.pubDate!.getFullYear()}`}
13+
/>
14+
</head>
15+
<body> </body>
16+
</html>

src/pages/contact.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const social = await getCollection('social')
5757
{' '}
5858
<a
5959
href={method.data.link}
60-
class='text-rosely9 hover:text-rosely-c dark:text-rosely-a dark:hover:text-rosely5'
60+
class='text-rosely9 hover:text-roselyc dark:text-roselya dark:hover:text-rosely5'
6161
>
6262
{method.data.link}
6363
</a>

src/pages/index.astro

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ const categories = await getCollection('category')
4545
<div class='rounded-md shadow-sm'>
4646
<a
4747
href={import.meta.env.BASE_URL + 'bio'}
48-
class='bg-rosely9 hover:bg-rosely-c dark:bg-rosely-b dark:text-rosely0 dark:hover:bg-rosely5 flex w-full items-center justify-center rounded-md border border-transparent px-8 py-2 text-base font-medium text-white md:px-10 md:py-3 md:text-lg'
48+
class='bg-rosely9 hover:bg-roselyc dark:bg-roselyb dark:text-rosely0 dark:hover:bg-rosely5 flex w-full items-center justify-center rounded-md border border-transparent px-8 py-2 text-base font-medium text-white md:px-10 md:py-3 md:text-lg'
4949
>
5050
About Me
5151
</a>
5252
</div>
5353
<div class='mt-3 sm:mt-0 sm:ml-3'>
5454
<a
55-
href={import.meta.env.BASE_URL + 'blog'}
56-
class='bg-rosely-a text-rosely0 hover:bg-rosely5 dark:bg-rosely1 dark:text-rosely-b dark:hover:bg-rosely8 flex w-full items-center justify-center rounded-md border border-transparent px-8 py-2 text-base font-medium md:px-10 md:py-3 md:text-lg'
55+
href={import.meta.env.BASE_URL + 'blog/' + posts[0].data.pubDate!.getFullYear()}
56+
class='bg-roselya text-rosely0 hover:bg-rosely5 dark:bg-rosely1 dark:text-roselyb dark:hover:bg-rosely8 flex w-full items-center justify-center rounded-md border border-transparent px-8 py-2 text-base font-medium md:px-10 md:py-3 md:text-lg'
5757
rel='noopener noreferrer'
5858
target='_blank'
5959
>
@@ -63,50 +63,50 @@ const categories = await getCollection('category')
6363
</div>
6464
</Carousel>
6565
<div class='bg-rosely7 dark:bg-rosely1 flex flex-row items-center p-4 sm:px-6 lg:px-8'>
66-
<h2 class='text-rosely8 dark:text-rosely-b text-2xl font-extrabold md:text-4xl'>
66+
<h2 class='text-rosely8 dark:text-roselyb text-2xl font-extrabold md:text-4xl'>
6767
Featured websites
6868
</h2>
6969
<a
7070
href={import.meta.env.BASE_URL + 'websites'}
71-
class='dark:hover:brosely5 bg-rosely9 hover:bg-rosely-c dark:bg-rosely-b dark:text-rosely0 mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold text-white md:text-lg'
71+
class='dark:hover:brosely5 bg-rosely9 hover:bg-roselyc dark:bg-roselyb dark:text-rosely0 mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold text-white md:text-lg'
7272
>
7373
All Websites
7474
</a>
7575
</div>
7676
<WebRoll featured={true} />
7777
<h2
78-
class='text-rosely8 dark:text-rosely-b mx-auto p-4 text-2xl font-extrabold sm:mx-2 md:text-4xl lg:mx-4'
78+
class='text-rosely8 dark:text-roselyb mx-auto p-4 text-2xl font-extrabold sm:mx-2 md:text-4xl lg:mx-4'
7979
>
8080
My Interests
8181
</h2>
8282
<CategoryRoll categories={categories} />
8383
<div class='bg-rosely7 dark:bg-rosely1 flex flex-row items-center p-4 sm:px-6 lg:px-8'>
84-
<h2 class='text-rosely8 dark:text-rosely-b text-2xl font-extrabold md:text-4xl'>
84+
<h2 class='text-rosely8 dark:text-roselyb text-2xl font-extrabold md:text-4xl'>
8585
My Latest Articles
8686
</h2>
8787
<a
88-
href={import.meta.env.BASE_URL + 'blog'}
89-
class='dark:hover:brosely5 bg-rosely9 hover:bg-rosely-c dark:bg-rosely-b dark:text-rosely0 mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold text-white md:text-lg'
88+
href={import.meta.env.BASE_URL + 'blog/' + posts[0].data.pubDate!.getFullYear()}
89+
class='dark:hover:brosely5 bg-rosely9 hover:bg-roselyc dark:bg-roselyb dark:text-rosely0 mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold text-white md:text-lg'
9090
>
9191
All Articles
9292
</a>
9393
<a
9494
href={import.meta.env.BASE_URL + 'categories'}
95-
class='bg-rosely-a text-rosely0 hover:bg-rosely5 dark:bg-rosely8 dark:text-rosely-b dark:hover:bg-rosely-c mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold md:text-lg'
95+
class='bg-roselya text-rosely0 hover:bg-rosely5 dark:bg-rosely8 dark:text-roselyb dark:hover:bg-roselyc mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold md:text-lg'
9696
>
9797
Categories
9898
</a>
9999
<a
100100
href={import.meta.env.BASE_URL + 'tags'}
101-
class='bg-rosely-a text-rosely0 hover:bg-rosely5 dark:bg-rosely8 dark:text-rosely-b dark:hover:bg-rosely-c mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold md:text-lg'
101+
class='bg-roselya text-rosely0 hover:bg-rosely5 dark:bg-rosely8 dark:text-roselyb dark:hover:bg-roselyc mt-2 ml-4 inline-block rounded-md px-2 py-2 text-base font-semibold md:text-lg'
102102
>
103103
Tags
104104
</a>
105105
</div>
106106
<BlogRoll posts={posts.slice(0, PAGE_SIZE)}>
107107
<a
108-
href={import.meta.env.BASE_URL + 'blog/2'}
109-
class='dark:hover:brosely5 bg-rosely9 hover:bg-rosely-c dark:bg-rosely-b dark:text-rosely0 mt-4 inline-block rounded-md p-2 text-base font-semibold text-white md:text-lg'
108+
href={import.meta.env.BASE_URL + 'blog'}
109+
class='dark:hover:brosely5 bg-rosely9 hover:bg-roselyc dark:bg-roselyb dark:text-rosely0 mt-4 inline-block rounded-md p-2 text-base font-semibold text-white md:text-lg'
110110
>
111111
More Articles
112112
</a>

0 commit comments

Comments
 (0)