rss and blog/project headers

This commit is contained in:
Chris W 2023-12-09 11:13:22 -07:00
parent 97027c9ac6
commit e5ad5b77f4
10 changed files with 105 additions and 1 deletions

View File

@ -7,6 +7,10 @@
{
"title": "blog",
"path": "[[workspace]]/src/content/posts"
},
{
"title": "projects",
"path": "[[workspace]]/src/content/projects"
}
],
"frontMatter.taxonomy.contentTypes": [
@ -53,6 +57,60 @@
"type": "tags"
}
]
},
{
"name": "project",
"pageBundle": false,
"previewPath": "'projects'",
"filePrefix": null,
"clearEmpty": true,
"fields": [
{
"title": "Name",
"name": "name",
"type": "string",
"single": true
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "URL",
"name": "url",
"type": "string"
},
{
"title": "Publishing date",
"name": "pubDate",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Hero image",
"name": "heroImage",
"type": "image",
"isPreviewImage": true
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Featured",
"name": "featured",
"type": "boolean"
},
{
"title": "Link only",
"name": "linkOnly",
"type": "boolean"
}
]
}
]
}

View File

@ -16,6 +16,7 @@ const projects = defineCollection({
name: z.string(),
description: z.string(),
url: z.string(),
pubDate: z.coerce.date(),
heroImage: z.string().optional(),
tags: z.array(z.string()).optional(),
featured: z.boolean().optional(),

View File

@ -8,6 +8,8 @@ tags:
- nlp
- linguistics
- library
pubDate: 2023-12-08T18:06:53.000Z
heroImage: /images/cadmium-header.png
linkOnly: true
type: project
---

View File

@ -7,8 +7,10 @@ tags:
- rust
- server
- self-hosted
pubDate: 2023-12-08T18:06:49.000Z
featured: true
heroImage: /images/inkify-header.webp
type: project
---
import CodeToImg from '../../components/inkify/CodeToImg.vue'

View File

@ -10,5 +10,7 @@ tags:
- webdriver
linkOnly: true
featured: true
pubDate: 2023-12-08T18:06:45.000Z
heroImage: /images/marionette-header.webp
type: project
---

View File

@ -8,6 +8,8 @@ tags:
- crystal
- bot
- framework
pubDate: 2023-12-08T18:06:35.000Z
heroImage: /images/tourmaline-header.png
linkOnly: true
type: project
---

View File

@ -1,4 +1,5 @@
---
import { Icon } from 'astro-icon/components';
import BaseHead from '../../components/BaseHead.astro';
import Header from '../../components/Header.astro';
import Footer from '../../components/Footer.astro';
@ -19,6 +20,9 @@ const posts = (await getCollection('posts')).sort(
main {
width: 960px;
}
h1 {
@apply flex items-center justify-center mb-12 gap-4;
}
ul {
@apply flex flex-wrap gap-8 list-none m-0 p-0;
}
@ -76,6 +80,12 @@ const posts = (await getCollection('posts')).sort(
<Header />
<main>
<section>
<h1>
<span>Blog</span>
<a target="_blank" href="/posts/rss.xml">
<Icon name="mdi:rss" />
</a>
</h1>
<ul>
{
posts

View File

@ -1,6 +1,6 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts';
export async function GET(context) {
const posts = await getCollection('posts');

View File

@ -1,4 +1,5 @@
---
import { Icon } from 'astro-icon/components';
import BaseHead from '../../components/BaseHead.astro';
import Header from '../../components/Header.astro';
import Footer from '../../components/Footer.astro';
@ -22,6 +23,9 @@ const projects = (await getCollection('projects'))
main {
width: 960px;
}
h1 {
@apply flex items-center justify-center mb-12 gap-4;
}
ul {
@apply flex flex-wrap gap-8 list-none m-0 p-0;
}
@ -74,6 +78,12 @@ const projects = (await getCollection('projects'))
<body>
<Header />
<main>
<h1>
<span>Projects</span>
<a target="_blank" href="/projects/rss.xml">
<Icon name="mdi:rss" />
</a>
</h1>
<section>
<ul>
{

View File

@ -0,0 +1,17 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts';
export async function GET(context) {
const projects = await getCollection('projects');
return rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: context.site,
items: projects.map((project) => ({
title: project.data.name,
pubDate: project.data.pubDate,
link: project.data.linkOnly ? project.data.url : `/projects/${project.slug}/`,
})),
});
}