From 95353ca21ea224b9f43146f9a51d1ac6ee64f78c Mon Sep 17 00:00:00 2001 From: riiim400th Date: Thu, 1 Jan 2026 11:59:33 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20rss=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/rss.xml.js | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index d691c62..754dcc6 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -2,6 +2,66 @@ import rss from '@astrojs/rss'; import { getCollection } from 'astro:content'; import siteInfo from '@/data/siteInfo'; +function extractImageUrl(body, contextSite) { + if (!body) return null; + const relativeImages = []; + const absoluteImages = []; + const imgTagRegex = /]+src=["']([^"']+)["'][^>]*>/g; + const mdImageRegex = /!\[[^\]]*\]\(([^)]+)\)/g; + + const imgMatches = [...body.matchAll(imgTagRegex)]; + const mdMatches = [...body.matchAll(mdImageRegex)]; + const allUrls = [ + ...imgMatches.map(match => match[1]), + ...mdMatches.map(match => match[1]) + ]; + + if (allUrls.length === 0) return null; + + for (const url of allUrls) { + const isRelative = url.startsWith('/'); + let fullUrl = url; + const ext = fullUrl.split('?')[0].split('.').pop()?.toLowerCase(); + let type; + + switch (ext) { + case 'jpg': + case 'jpeg': + type = 'image/jpeg'; + break; + case 'png': + type = 'image/png'; + break; + case 'gif': + type = 'image/gif'; + break; + case 'webp': + type = 'image/webp'; + break; + case 'svg': + type = 'image/svg+xml'; + break; + default: + continue; + } + + const imageObj = { + url: fullUrl, + type: type, + length: 0 + }; + + if (isRelative) { + relativeImages.push(imageObj); + } else { + absoluteImages.push(imageObj); + } + } + + const images = [...relativeImages, ...absoluteImages]; + return images.length > 0 ? images : null; +} + export async function GET(context) { const blogs = await getCollection('blog'); return rss({ @@ -14,6 +74,12 @@ export async function GET(context) { description: blog.data.description, customData: blog.data.customData, link: `/blog/${blog.slug}/`, + categories: blog.data.tags, + enclosure: extractImageUrl(blog.body, context.site)?.[0] || { + url: new URL(`/og/${blog.slug}.png`, context.site).toString(), + type: 'image/png', + length: 0, + }, })), customData: `ja-jp`, }); From e26b7edea9747546f7be67705d4e9153e11e1804 Mon Sep 17 00:00:00 2001 From: riiim400th Date: Fri, 2 Jan 2026 08:22:00 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=A8=20feat:=20alternate=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/BlogLayout.astro | 1 + src/layouts/Layout.astro | 1 + 2 files changed, 2 insertions(+) diff --git a/src/layouts/BlogLayout.astro b/src/layouts/BlogLayout.astro index 504c5db..de0481e 100644 --- a/src/layouts/BlogLayout.astro +++ b/src/layouts/BlogLayout.astro @@ -37,6 +37,7 @@ const authorX = author?.links?.find(l => l.name === 'X')?.id; +