RSSHub/lib/routes/amazon/awsblogs.ts

44 lines
1.7 KiB
TypeScript

import type { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/awsblogs/:locale?',
categories: ['blog'],
example: '/amazon/awsblogs',
parameters: {
locale: 'Blog posts in a specified language, only the following options are supported. Default `zh_CN`',
},
description: `| zh\\_CN | en\\_US | fr\\_FR | de\\_DE | ja\\_JP | ko\\_KR | pt\\_BR | es\\_ES | ru\\_RU | id\\_ID | tr\\_TR |
| ------- | ------- | ------ | ------ | -------- | ------ | ---------- | ------- | ------- | ---------- | ------- |
| Chinese | English | French | German | Japanese | Korean | Portuguese | Spanish | Russian | Indonesian | Turkish |`,
name: 'AWS Blogs',
maintainers: ['HankChow'],
handler,
};
async function handler(ctx) {
const locale = ctx.req.param('locale') ?? 'zh_CN';
const response = await got({
url: `https://aws.amazon.com/api/dirs/items/search?item.directoryId=blog-posts&sort_by=item.additionalFields.createdDate&sort_order=desc&size=50&item.locale=${locale}`,
});
const items = response.data.items;
return {
title: 'AWS Blog',
link: 'https://aws.amazon.com/blogs/',
description: 'AWS Blog 更新',
item:
items &&
items.map((item) => ({
title: item.item.additionalFields.title,
description: item.item.additionalFields.postExcerpt,
pubDate: parseDate(item.item.dateCreated),
link: item.item.additionalFields.link,
author: item.item.additionalFields.contributors,
})),
};
}