-
Notifications
You must be signed in to change notification settings - Fork 9.9k
feat: add aiera.com.cn 新智元 RSS route #22118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
panqingjie00
wants to merge
7
commits into
DIYgod:master
Choose a base branch
from
panqingjie00:feat/aiera-latest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+70
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05d06b1
Merge pull request #1 from DIYgod/master
pull[bot] 7d2aaa3
Merge pull request #2 from DIYgod/master
pull[bot] ae34cd0
add: aiera.com.cn 新智元 RSS 路由
panqingjie00 5bcb15d
add: aiera.com.cn 新智元最新文章 RSS 路由
panqingjie00 ad40f54
fix: use cache from @/utils/cache instead of ctx.cache
panqingjie00 fde16c3
fix: resolve oxlint errors, remove unused ctx parameter
panqingjie00 14d218a
fix: add feed image (site icon) to aiera route
panqingjie00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import type { Route } from '@/types'; | ||
| import cache from '@/utils/cache'; | ||
| import got from '@/utils/got'; | ||
| import { parseDate } from '@/utils/parse-date'; | ||
|
|
||
| export const route: Route = { | ||
| path: '/latest', | ||
| categories: ['new-media'], | ||
| example: '/aiera/latest', | ||
| url: 'aiera.com.cn', | ||
| name: '最新文章', | ||
| maintainers: ['panqingjie00'], | ||
| features: { | ||
| requireConfig: false, | ||
| requirePuppeteer: false, | ||
| antiCrawler: false, | ||
| supportBT: false, | ||
| supportPodcast: false, | ||
| supportScihub: false, | ||
| }, | ||
| radar: [ | ||
| { | ||
| source: ['aiera.com.cn'], | ||
| target: '/latest', | ||
| }, | ||
| ], | ||
| handler, | ||
| }; | ||
|
|
||
| async function handler() { | ||
| const response = await cache.tryGet('aiera:latest', async () => { | ||
| const { data } = await got('https://aiera.com.cn/wp-json/wp/v2/posts', { | ||
| searchParams: { | ||
| per_page: 20, | ||
| _embed: '', | ||
| }, | ||
| }); | ||
| return data; | ||
| }); | ||
|
|
||
| if (!Array.isArray(response)) { | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| throw new TypeError('Invalid API response'); | ||
| } | ||
|
|
||
| const items = response.map((item) => ({ | ||
| title: item.title.rendered, | ||
| description: item.content.rendered, | ||
| pubDate: parseDate(item.date_gmt), | ||
| link: item.link, | ||
| guid: item.guid.rendered, | ||
| author: item._embedded?.author?.[0]?.name, | ||
| })); | ||
|
|
||
| return { | ||
| title: '新智元 - 最新文章', | ||
| link: 'https://aiera.com.cn', | ||
| description: '新智元最新 AI 新闻资讯', | ||
| language: 'zh-CN', | ||
| image: 'https://aiera.com.cn/wp-content/uploads/2025/01/%E6%96%B0%E6%99%BA%E5%85%83%E7%BD%91%E7%AB%99logo-150x150.png', | ||
| item: items, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import type { Namespace } from '@/types'; | ||
|
|
||
| export const namespace: Namespace = { | ||
| name: '新智元', | ||
| url: 'aiera.com.cn', | ||
| lang: 'zh-CN', | ||
| description: '新智元 - AI 新闻资讯平台', | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't cache the response as it will refresh the cache duration on each request. This means the entries won't be updated once it's cached.