Files
RSSHub/lib/routes/google/developers.ts
T
dependabot[bot]andTonyRL 6bce9493b5 chore(deps-dev): bump eslint-plugin-unicorn from 71.1.0 to 72.0.0 (#22723)
* chore(deps-dev): bump eslint-plugin-unicorn from 71.1.0 to 72.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 71.1.0 to 72.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v71.1.0...v72.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 72.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: fix prefer-dom-node-html-methods

* style: fix prefer-split-limit

* style: fix no-unnecessary-string-trim

* style: fix no-multiple-promise-resolver-calls

* style: add v72 preset

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2026-07-15 23:11:15 +08:00

73 lines
2.2 KiB
TypeScript

import { load } from 'cheerio';
import type { Context } from 'hono';
import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://developers.googleblog.com';
export const route: Route = {
path: '/developers/:locale?',
name: 'Developers Blog',
url: 'developers.googleblog.com',
maintainers: ['Loongphy'],
handler,
example: '/google/developers/en',
parameters: {
locale: {
description: 'language',
default: 'en',
options: [
{ value: 'en', label: 'English' },
{ value: 'es', label: 'Español (Latam)' },
{ value: 'id', label: 'Bahasa Indonesia' },
{ value: 'ja', label: '日本語' },
{ value: 'ko', label: '한국어' },
{ value: 'pt-br', label: 'Português (Brasil)' },
{ value: 'zh-hans', label: '简体中文' },
],
},
},
description: 'Google Developers Blog',
categories: ['blog'],
radar: [
{
source: ['developers.googleblog.com'],
},
],
};
async function handler(ctx: Context) {
const locale = ctx.req.param('locale') ?? 'en';
const response = await ofetch(`${baseUrl}/${locale}/search`);
const $ = load(response);
const items = $('.search-result')
.toArray()
.map((element) => {
const dateCategory = $(element).find('.search-result__eyebrow').text().trim();
const [date, category] = dateCategory.split(' / ', 2);
const titleElement = $(element).find('.search-result__title a');
const title = titleElement.text().trim();
const link = titleElement.attr('href');
const summary = $(element).find('.search-result__summary').text().trim();
return {
title,
link: `${baseUrl}${link}`,
pubDate: parseDate(date),
description: summary,
author: 'Google',
category: [category],
};
});
return {
title: 'Google Developers Blog',
link: baseUrl,
item: items,
};
}