Skip to content

Commit

Permalink
Add RSS & webring
Browse files Browse the repository at this point in the history
  • Loading branch information
thammarith committed Oct 7, 2023
1 parent b33dbac commit 2817292
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/rss": "^3.0.0",
"@astrojs/solid-js": "^3.0.0",
"@astrojs/tailwind": "^5.0.0",
"@fortawesome/fontawesome-free": "^6.4.2",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import type { Component } from 'solid-js';

import Link from './Link';

const ThaiWebRing = () => (
<a class="block mt-12" href="https://webring.wonderful.software#thammarith.dev" title="วงแหวนเว็บ">
<img class="w-8 h-8 opacity-80" alt="วงแหนเว็บ" src="https://webring.wonderful.software/webring.white.svg" />
</a>
);

const Footer: Component = () => (
<footer class="px-8 py-16 sm:px-16 bg-slate-900 flex flex-grow-0 items-center justify-center">
<div class="w-full max-w-[72ch] text-white font-['Figtree']">
<footer class="px-8 py-16 sm:px-16 bg-slate-900 flex flex-col flex-grow-0 items-center justify-center">
<div class="relative w-full max-w-[72ch] text-white font-['Figtree']">
<h2 class="text-slate-100 font-['Poppins'] font-semibold text-3xl">thammarith.dev</h2>

<div id="licence" class="font-text mt-12 text-slate-400">
Expand Down Expand Up @@ -34,6 +40,7 @@ const Footer: Component = () => (
</p>
</div>
</div>
<ThaiWebRing />
</footer>
// <a
// class={[
Expand Down
21 changes: 21 additions & 0 deletions src/content/blog/classical-music-concert-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# kicker: ไปฟังดนตรีคลาสสิกกันเถอะ
title: วิธีฟังดนตรีคลาสสิก ฉบับมือใหม่
subtitle: ไม่ใช่นักดนตรีก็ฟังดนตรีคลาสสิกได้! แล้วคุณจะไม่มองว่าดนตรีคลาสสิกน่าเบื่ออีกต่อไป
excerpt: z.string().optional()
link: sdfsdfdf
# image: z.string().optional(),
pubDate: 2023-10-07
tags: []
---

คุณนึกถึงอะไรเมื่อพูดถึงดนตรีคลาสสิก? หลายคนนึงถึงเสียงดนตรีอันเชื่องช้า น่าเบื่อหน่าย หลายคนรู้สึกว่ามันยิ่งใหญ่ ห่างไกลตัว เข้าถึงยาก เป็นงานรวมคนแก่

ผมจะลองเล่าเรื่องเกี่ยวกับดนตรีคลาสสิก และวิธีฟังให้คุณฟัง ในมุมของคนที่ไม่ใช่ศิลปิน เล่นดนตรีไม่เป็นสักชิ้น อ่านโน้ตดนตรีก็ไม่เป็น แต่ก็กระเสือกกระสนอยากลองฟัง เผื่อสุดท้ายแล้วคุณจะมาสนใจดนตรีคลาสสิกเหมือนกันกับผม

:::note[Using an Astro layout?]
ไม่ต้องห่วง! บทความนี้เขียนโดยคนไม่มีความรู้ด้านดนตรี ผมพยายามใช้ภาษาที่เรียบง่ายที่สุด และอธิบายศัพท์ทางทฤษฎีดนตรีไว้ (ถ้าจำเป็นต้องใช้อะนะ)
:::

> [!IMPORTANT]
> Crucial information necessary for users to succeed.
5 changes: 5 additions & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This can be moved out to their own schemas
// https://docs.astro.build/en/guides/content-collections/#defining-multiple-collections
import { defineCollection, z } from 'astro:content';
import { rssSchema } from '@astrojs/rss';

const articleCollection = defineCollection({
type: 'content',
Expand All @@ -14,9 +15,13 @@ const articleCollection = defineCollection({
const blogCollection = defineCollection({
type: 'content',
schema: z.object({
kicker: z.string().optional(),
title: z.string(),
subtitle: z.string().optional(),
excerpt: z.string().optional(),
tags: z.array(z.string()),
image: z.string().optional(),
pubDate: z.date(),
}),
});

Expand Down
21 changes: 21 additions & 0 deletions src/pages/blog/[slug].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
const blogEntries = await getCollection('blog');
return blogEntries.map(entry => ({
params: { slug: entry.slug }, props: { entry },
}));
}
const { entry } = Astro.props;
const { Content } = await entry.render();
---
<meta charset="utf-8" />

<!-- <div>
{JSON.stringify(entry)}
</div> -->

<h1>{entry.data.title}</h1>
<Content />
21 changes: 21 additions & 0 deletions src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';

export const GET = async (context: any) => {
const blogEntries = await getCollection('blog');

const entries = blogEntries.map((post) => ({
title: post.data.title,
pubDate: post.data.pubDate,
description: post.data.excerpt,
// customData: post.data.customData,
link: `/blog/${post.slug}/`,
}));

return rss({
title: 'Latest from thammarith.dev',
description: 'See what Thammarith has finally wrote!',
site: context.site,
items: entries,
});
};

0 comments on commit 2817292

Please sign in to comment.