From 4cd2d334b3b3a69d5c7b084d27b9bb47152a461c Mon Sep 17 00:00:00 2001 From: Cedar Date: Mon, 23 Sep 2024 10:22:16 +0800 Subject: [PATCH] feat: add RSS Tag-based authentication for feed ownership in Follow (https://follow.is) - Implemented RSS Tag-based authentication to verify feed ownership in Follow (follow.is). - Only the RSS Tag method was considered, while the other two options were not implemented. - Updated RSS generation logic to support ownership claim verification via RSS tags. --- src/config.json | 5 +++++ src/content/posts/guide.md | 6 ++++++ src/pages/rss.xml.ts | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/config.json b/src/config.json index 7af9106..053bb63 100644 --- a/src/config.json +++ b/src/config.json @@ -115,5 +115,10 @@ "microsoftClarity": { "projectId": "" } + }, + "follow":{ + "enable": false, + "feedId":"", + "userId":"" } } diff --git a/src/content/posts/guide.md b/src/content/posts/guide.md index 8b0a9d7..2512fe9 100644 --- a/src/content/posts/guide.md +++ b/src/content/posts/guide.md @@ -146,6 +146,12 @@ pnpm preview "microsoftClarity": { "projectId": "" } + }, + //如果需要在 Follow(https://follow.is) 中认证订阅源,将 enable 修改为 true,并填写 feedId、userId + ”follow“:{ + ”enable“: false, + ”feedId“:”“, + ”userId“:”“ } } ``` diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 2eeebeb..52a5711 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -1,10 +1,24 @@ import type { APIContext } from 'astro' import rss from '@astrojs/rss' -import { site } from '@/config.json' +import { site, follow } from '@/config.json' import { getSortedPosts } from '@/utils/content' export async function GET(context: APIContext) { const sortedPosts = await getSortedPosts() + + const generateCustomData = () => { + let customData = `${site.lang}\n` + + if (follow?.enable && follow.feedId && follow.userId) { + customData += ` + + ${follow.feedId} + ${follow.userId} + ` + } + + return customData + } return rss({ title: site.title, @@ -16,6 +30,6 @@ export async function GET(context: APIContext) { pubDate: post.data.date, description: post.data.summary, })), - customData: `${site.lang}`, + customData: generateCustomData(), }) }