From 20869a3c45de95a839ad17e313e5ddd4fd088997 Mon Sep 17 00:00:00 2001 From: QunLIn Date: Sat, 3 Oct 2026 01:19:02 +0800 Subject: [PATCH] =?UTF-8?q?RSS=20API=20=E5=9C=B0=E5=9D=80=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=94=B6=E6=95=9B=E5=88=B0=20hugo.toml=20[params.rssa?= =?UTF-8?q?pi]=EF=BC=8C=E5=88=87=E5=88=B0=20api.200181.xyz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 [params.rssapi] base 配置,主题 7 处硬编码改为读配置: head(preconnect+window.rssApiBase)、footer(构建时拉 links/feeds)、 render-link(favicon)、circles/links 页 fetch、linkify.js(读 window.rssApiBase) - scripts/fetch_greetings.js 支持 RSS_API_BASE 环境变量,默认新地址 - scfapi.usj.cc(国内代理)保持不变 --- hugo.toml | 7 +++++++ scripts/fetch_greetings.js | 2 +- themes/Ying/assets/js/modules/linkify.js | 2 +- themes/Ying/layouts/_default/_markup/render-link.html | 2 +- themes/Ying/layouts/page/circles.html | 2 +- themes/Ying/layouts/page/links.html | 2 +- themes/Ying/layouts/partials/footer.html | 4 ++-- themes/Ying/layouts/partials/head.html | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hugo.toml b/hugo.toml index 055b2c4e..8b8d7a7f 100644 --- a/hugo.toml +++ b/hugo.toml @@ -190,6 +190,13 @@ hasCJKLanguage = true emoticons = "/emotion/OwO.json" gravatar = "https://cravatar.cn/avatar/" + # ---------------------------------------------------------------------------- + # RSS 聚合服务 (rss-robot-cf:订阅/友链/文章/图标) + # ---------------------------------------------------------------------------- + [params.rssapi] + # 2026-10-02 从 EdgeOne (https://api.usj.cc) 迁到 Cloudflare Workers + base = "https://api.200181.xyz" + # ---------------------------------------------------------------------------- # 弹幕配置 (Barrage Configuration) # ---------------------------------------------------------------------------- diff --git a/scripts/fetch_greetings.js b/scripts/fetch_greetings.js index 286c6e99..28af4775 100644 --- a/scripts/fetch_greetings.js +++ b/scripts/fetch_greetings.js @@ -7,7 +7,7 @@ const fs = require("fs"); const path = require("path"); -const API_BASE = "https://api.usj.cc/api/ai/greeting"; +const API_BASE = (process.env.RSS_API_BASE || "https://api.200181.xyz") + "/api/ai/greeting"; let TOKEN = process.env.RSS_API_TOKEN; // Fallback: read from write/.env diff --git a/themes/Ying/assets/js/modules/linkify.js b/themes/Ying/assets/js/modules/linkify.js index 6a34dcfb..941772f2 100644 --- a/themes/Ying/assets/js/modules/linkify.js +++ b/themes/Ying/assets/js/modules/linkify.js @@ -2,7 +2,7 @@ (function() { var URL_RE = /(https?:\/\/[^\s一-鿿 -〿＀-￯<>"')\]]+)/g; var VIDEO_RE = /\.(mp4|webm|ogg|mov)(\?|$)/i; - var FAVICON_API = 'https://api.usj.cc/api/favicon?url='; + var FAVICON_API = (window.rssApiBase || 'https://api.200181.xyz') + '/api/favicon?url='; function getDomain(url) { try { return new URL(url).hostname; } catch (e) { return url; } diff --git a/themes/Ying/layouts/_default/_markup/render-link.html b/themes/Ying/layouts/_default/_markup/render-link.html index 0461c62c..2a719ce4 100644 --- a/themes/Ying/layouts/_default/_markup/render-link.html +++ b/themes/Ying/layouts/_default/_markup/render-link.html @@ -10,7 +10,7 @@ {{- else if $isExternal -}} {{- $domain := urls.Parse $url -}} -{{- $faviconUrl := printf "https://api.usj.cc/api/favicon?url=%s" $domain.Host -}} +{{- $faviconUrl := printf "%s/api/favicon?url=%s" (site.Params.rssapi.base | default "https://api.200181.xyz") $domain.Host -}} {{- if $isBareUrl -}} diff --git a/themes/Ying/layouts/page/circles.html b/themes/Ying/layouts/page/circles.html index bd8c0408..ab49b4c0 100644 --- a/themes/Ying/layouts/page/circles.html +++ b/themes/Ying/layouts/page/circles.html @@ -448,7 +448,7 @@ hardTtl: window.BrowserCache ? window.BrowserCache.formatDuration(window.FriendCircle.CACHE_OPTIONS.hardTtl) : window.FriendCircle.CACHE_OPTIONS.hardTtl }); } - return fetch("https://api.usj.cc/api/articles?limit=50") + return fetch("{{ site.Params.rssapi.base | default "https://api.200181.xyz" }}/api/articles?limit=50") .then(function(res) { if (!res.ok) throw new Error("Network response was not ok"); return res.json(); diff --git a/themes/Ying/layouts/page/links.html b/themes/Ying/layouts/page/links.html index a95a63f0..d71895ec 100644 --- a/themes/Ying/layouts/page/links.html +++ b/themes/Ying/layouts/page/links.html @@ -220,7 +220,7 @@ softTtl: window.BrowserCache ? window.BrowserCache.formatDuration(CACHE_OPTIONS.softTtl) : CACHE_OPTIONS.softTtl, hardTtl: window.BrowserCache ? window.BrowserCache.formatDuration(CACHE_OPTIONS.hardTtl) : CACHE_OPTIONS.hardTtl }); - return fetch('https://api.usj.cc/api/links') + return fetch('{{ site.Params.rssapi.base | default "https://api.200181.xyz" }}/api/links') .then(function(res) { if (!res.ok) throw new Error('Failed to fetch links'); return res.json(); diff --git a/themes/Ying/layouts/partials/footer.html b/themes/Ying/layouts/partials/footer.html index cc82ffa4..c132f68a 100644 --- a/themes/Ying/layouts/partials/footer.html +++ b/themes/Ying/layouts/partials/footer.html @@ -80,7 +80,7 @@ {{/* Fetch friend data at build time — no runtime network requests */}} {{ $linkHosts := slice }} {{ $linkNames := slice }} -{{ with resources.GetRemote "https://api.usj.cc/api/links?all=1" }} +{{ with resources.GetRemote (printf "%s/api/links?all=1" (site.Params.rssapi.base | default "https://api.200181.xyz")) }} {{ with .Err }} {{ warnf "Links API fetch failed: %s" . }} {{ else }} @@ -107,7 +107,7 @@ {{ $feedHosts := slice }} {{ $feedNames := slice }} -{{ with resources.GetRemote "https://api.usj.cc/api/feeds" }} +{{ with resources.GetRemote (printf "%s/api/feeds" (site.Params.rssapi.base | default "https://api.200181.xyz")) }} {{ with .Err }} {{ warnf "Feeds API fetch failed: %s" . }} {{ else }} diff --git a/themes/Ying/layouts/partials/head.html b/themes/Ying/layouts/partials/head.html index 07002fd6..81eb180c 100644 --- a/themes/Ying/layouts/partials/head.html +++ b/themes/Ying/layouts/partials/head.html @@ -42,7 +42,8 @@ - + {{ with site.Params.rssapi.base }}{{ end }} + {{ with site.Params.rssapi.base }}{{ end }}