feat(route): add router for engineering.fyi (#19899)

* feat(route): add router for engineering.fyi

* fix: take the suggested change

---------

Co-authored-by: suhangj <suhangj@enn.cn>
This commit is contained in:
suhang-only 2025-08-25 22:57:28 +08:00 committed by GitHub
parent feaf7ab924
commit 00cf551de4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Engineering.fyi',
url: 'engineering.fyi',
description: 'Programming Tutorials and Engineering Articles',
lang: 'en',
};

View File

@ -0,0 +1,55 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
export const route: Route = {
path: '/tag/:tag',
categories: ['programming'],
example: '/engineering/tag/javascript',
parameters: { tag: 'Browse programming languages, frameworks, and technologies' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['engineering.fyi/tag/:tag'],
},
],
name: 'Tag',
maintainers: ['suhang-only'],
handler,
description: `| JSON | Javascript | Java | Apache | AWS | SQL | React | Golang |
| ---- | ---------- | ---- | ------ | --- | --- | ----- | ------ |
| json | javascript | java | apache | aws | sql | react | golang |`,
};
async function handler(ctx) {
const tag = ctx.req.param('tag');
const { data: response } = await got(`https://engineering.fyi/tag/${tag}`);
const $ = load(response);
const items = $('div.text-card-foreground')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a').eq(2);
const description = item.find('.leading-relaxed');
const author = item.find('.truncate');
return {
title: a.text(),
link: a.attr('href'),
description: description.text(),
author: author.text(),
};
});
return {
title: `engineering.fyi ${tag}`,
link: `https://engineering.fyi/tag/${tag}`,
item: items,
};
}