feat(route): Add 英語之家 - The Home of English feed (#19814)

* feat: add feed for englishhome

* fix: route issues

- add namespace.ts
- fix date parsing

* fix: route name and description

* refactor: use wordpress api

* fix: remove CDATA section

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Tsung-Han Yu
2025-08-13 02:21:47 +08:00
committed by GitHub
co-authored by google-labs-jules[bot]
parent 61c10aa55f
commit c65d8d6ae3
2 changed files with 61 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import { Route, type Data } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/',
categories: ['blog'],
example: '/englishhome',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['englishhome.org/'],
},
],
name: '首頁',
maintainers: ['johan456789'],
handler,
description: '英語之家 - The Home of English 首頁',
};
async function handler() {
const rootUrl = 'https://englishhome.org';
const apiUrl = `${rootUrl}/wp-json/wp/v2/posts?per_page=20&_embed=author,wp:term`;
const data = await ofetch<any[]>(apiUrl);
const items = data.map((post) => ({
title: post.title?.rendered,
description: post.content?.rendered ?? post.excerpt?.rendered ?? '',
link: post.link,
pubDate: parseDate(post.date_gmt ?? post.date),
author: post._embedded?.author?.[0]?.name,
category: Array.isArray(post._embedded?.['wp:term'])
? post._embedded['wp:term']
.flat()
.map((term: any) => term?.name)
.filter(Boolean)
: undefined,
}));
return {
title: '英語之家 - The Home of English',
link: rootUrl,
language: 'zh-TW',
item: items,
} as Data;
}
+6
View File
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '英語之家',
url: 'englishhome.org',
};