Files
RSSHub/lib/routes/theinitium/author.ts
T
8d8a435a48 fix(route/theinitium): rewrite for Ghost CMS after site migration (#21071)
* refactor(theinitium): rewrite routes for Ghost CMS, add cookie support

- Rewrite all routes to use Ghost Content API (old API deprecated)
- Add INITIUM_MEMBER_COOKIE env var for paid article full-text
- Add features block with requireConfig to all route files
- Add url field and radar rules per RSSHub standards
- Strip -zh-hans suffix from author/category display names
- Update namespace with English name and zh translations
- Mark follow route as deprecated (Ghost doesn't support it)
- Fix hostname binding to 0.0.0.0 for LAN access

* fix(theinitium): use routeExpire with refresh=false to prevent stale cache

Cache was never expiring because refresh=true (default) extends TTL on every hit.
Now uses 5-min routeExpire and won't extend on access.

* refactor(theinitium): address review feedback

- Remove unused INITIUM_USERNAME/PASSWORD/BEARER_TOKEN env keys
- Remove hardcoded User-Agent (use RSSHub's internal UA)
- Remove fragile html.length > 500 check
- Remove refresh: false from cache.tryGet
- Hoist stripLangSuffix to module scope (dedupe with cleanName)

* fix(theinitium): detect paywall CTA instead of length check

If cookie is invalid/expired, scrape returns paywall HTML.
Check for .gh-post-upgrade-cta to detect this and fall back
to cleaner Ghost API preview.

* revert(index): restore '::' hostname per #16513

* feat(theinitium): clean Ghost Koenig card HTML for RSS output

* fix(theinitium): use redirected Ghost API URL, remove unused config types

* fix(theinitium): remove unrelated neureality config changes

---------

Co-authored-by: Ryan Yao <ryanyao@Macmini.lan>
Co-authored-by: Ryan Yao <ryanyao@Ryans-Mac-mini.lan>
Co-authored-by: Ryan Yao <ryanyao@Ryans-Mac-mini.local>
2026-03-09 04:13:25 +08:00

40 lines
1.1 KiB
TypeScript

import type { Route } from '@/types';
import { processFeed } from './utils';
const handler = (ctx) => processFeed('author', ctx);
export const route: Route = {
path: '/author/:type/:language?',
name: '作者',
url: 'theinitium.com',
maintainers: ['AgFlore'],
parameters: {
type: '作者 slug,可从作者主页 URL 中获取,如 `https://theinitium.com/author/initium-newsroom/`',
language: '语言,简体`zh-hans`,繁体`zh-hant`,缺省为不限',
},
features: {
requireConfig: [
{
name: 'INITIUM_MEMBER_COOKIE',
optional: true,
description: '端传媒会员登录后的 Cookie,用于获取付费文章全文。',
},
],
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['theinitium.com/author/:type'],
target: '/author/:type',
},
],
handler,
example: '/theinitium/author/initium-newsroom',
categories: ['new-media'],
};