From e5ad5b77f4ded946f857aa9d15a522b98ce3a00a Mon Sep 17 00:00:00 2001 From: Chris W Date: Sat, 9 Dec 2023 11:13:22 -0700 Subject: [PATCH] rss and blog/project headers --- frontmatter.json | 58 ++++++++++++++++++++++++++++++ src/content/config.ts | 1 + src/content/projects/cadmium.md | 2 ++ src/content/projects/inkify.mdx | 2 ++ src/content/projects/marionette.md | 2 ++ src/content/projects/tourmaline.md | 2 ++ src/pages/posts/index.astro | 10 ++++++ src/pages/{ => posts}/rss.xml.js | 2 +- src/pages/projects/index.astro | 10 ++++++ src/pages/projects/rss.xml.js | 17 +++++++++ 10 files changed, 105 insertions(+), 1 deletion(-) rename src/pages/{ => posts}/rss.xml.js (85%) create mode 100644 src/pages/projects/rss.xml.js diff --git a/frontmatter.json b/frontmatter.json index b31627a..d6a9f36 100644 --- a/frontmatter.json +++ b/frontmatter.json @@ -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" + + } + ] } ] } \ No newline at end of file diff --git a/src/content/config.ts b/src/content/config.ts index bfbd196..0b2a84f 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -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(), diff --git a/src/content/projects/cadmium.md b/src/content/projects/cadmium.md index fbd5052..e74bbc1 100644 --- a/src/content/projects/cadmium.md +++ b/src/content/projects/cadmium.md @@ -8,6 +8,8 @@ tags: - nlp - linguistics - library +pubDate: 2023-12-08T18:06:53.000Z heroImage: /images/cadmium-header.png linkOnly: true +type: project --- diff --git a/src/content/projects/inkify.mdx b/src/content/projects/inkify.mdx index 62bcb75..c0060a3 100644 --- a/src/content/projects/inkify.mdx +++ b/src/content/projects/inkify.mdx @@ -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' diff --git a/src/content/projects/marionette.md b/src/content/projects/marionette.md index bf3e362..854db43 100644 --- a/src/content/projects/marionette.md +++ b/src/content/projects/marionette.md @@ -10,5 +10,7 @@ tags: - webdriver linkOnly: true featured: true +pubDate: 2023-12-08T18:06:45.000Z heroImage: /images/marionette-header.webp +type: project --- diff --git a/src/content/projects/tourmaline.md b/src/content/projects/tourmaline.md index 8953428..3843588 100644 --- a/src/content/projects/tourmaline.md +++ b/src/content/projects/tourmaline.md @@ -8,6 +8,8 @@ tags: - crystal - bot - framework +pubDate: 2023-12-08T18:06:35.000Z heroImage: /images/tourmaline-header.png linkOnly: true +type: project --- diff --git a/src/pages/posts/index.astro b/src/pages/posts/index.astro index 937a20d..41dddd1 100644 --- a/src/pages/posts/index.astro +++ b/src/pages/posts/index.astro @@ -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(
+

+ Blog + + + +

    { posts diff --git a/src/pages/rss.xml.js b/src/pages/posts/rss.xml.js similarity index 85% rename from src/pages/rss.xml.js rename to src/pages/posts/rss.xml.js index ab0a9fa..95592a6 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/posts/rss.xml.js @@ -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'); diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index 4ad4329..89dab80 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -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'))
    +

    + Projects + + + +

      { diff --git a/src/pages/projects/rss.xml.js b/src/pages/projects/rss.xml.js new file mode 100644 index 0000000..5a3f93c --- /dev/null +++ b/src/pages/projects/rss.xml.js @@ -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}/`, + })), + }); +}