mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 15:09:12 +00:00
feat: add RSS feed beautification option
Introduces a new RSS_BEAUTIFY configuration flag to enable RSS feed styling - Adds XSL styling support for RSS feeds when enabled - Updates documentation in both English and Chinese - Modifies RSS generation to support the new styling option Migration from rss to getRssString for enhanced customization
This commit is contained in:
@@ -23,4 +23,5 @@ GOOGLE_SEARCH_SITE=""
|
||||
TAGS=""
|
||||
COMMENTS=""
|
||||
LINKS=""
|
||||
NAVS=""
|
||||
NAVS=""
|
||||
RSS_BEAUTIFY=false
|
||||
@@ -133,6 +133,9 @@ LINKS=Title1,URL1;Title2,URL3;Title3,URL3;
|
||||
|
||||
## Sidebar Navigation Item, Separate using commas and semicolons
|
||||
NAVS=Title1,URL1;Title2,URL3;Title3,URL3;
|
||||
|
||||
## Enable RSS beautify
|
||||
RSS_BEAUTIFY=true
|
||||
```
|
||||
|
||||
## 🙋🏻 FAQs
|
||||
|
||||
@@ -131,6 +131,9 @@ LINKS=Title1,URL1;Title2,URL3;Title3,URL3;
|
||||
|
||||
## 侧边栏导航项, 使用英文逗号和分号分割
|
||||
NAVS=Title1,URL1;Title2,URL3;Title3,URL3;
|
||||
|
||||
## 启用 RSS 美化
|
||||
RSS_BEAUTIFY=true
|
||||
```
|
||||
|
||||
## 🙋🏻 常问问题
|
||||
|
||||
1
src/assets/rss.xsl
Normal file
1
src/assets/rss.xsl
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,8 @@
|
||||
import rss from '@astrojs/rss'
|
||||
import { getRssString } from '@astrojs/rss'
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
import { getChannelInfo } from '../lib/telegram'
|
||||
import { getEnv } from '../lib/env'
|
||||
import style from '../assets/rss.xsl?raw'
|
||||
|
||||
export async function GET(Astro) {
|
||||
const { SITE_URL } = Astro.locals
|
||||
@@ -15,7 +17,7 @@ export async function GET(Astro) {
|
||||
url.pathname = SITE_URL
|
||||
url.search = ''
|
||||
|
||||
return rss({
|
||||
let rssString = await getRssString({
|
||||
title: `${tag ? `${tag} | ` : ''}${channel.title}`,
|
||||
description: channel.description,
|
||||
site: url.origin,
|
||||
@@ -39,4 +41,16 @@ export async function GET(Astro) {
|
||||
}),
|
||||
})),
|
||||
})
|
||||
|
||||
const enableBeautify = getEnv(import.meta.env, Astro, 'RSS_BEAUTIFY')
|
||||
if (enableBeautify) {
|
||||
rssString = rssString.replace(/^(<\?xml .*\?>)/i, style)
|
||||
}
|
||||
|
||||
return new Response(rssString, {
|
||||
headers: {
|
||||
'Content-Type': 'text/xml',
|
||||
'Cache-Control': 'public, max-age=3600',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user