feat(route/claude): add claude code changelog route (#21347)

* feat(route/claude): add claude code changelog route

* fix: route title rule#2

* Update lib/routes/claude/code-changelog.ts

---------
This commit is contained in:
Rigo
2026-03-10 22:58:18 -07:00
committed by GitHub
parent a662e93486
commit 09a2886506
2 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
import type { CheerioAPI } from 'cheerio';
import { load } from 'cheerio';
import type { Context } from 'hono';
import type { Data, DataItem, Route } from '@/types';
import ofetch from '@/utils/ofetch';
const handler = async (ctx: Context): Promise<Data> => {
const limit = Number.parseInt(ctx.req.query('limit') ?? '25', 10);
const baseUrl = 'https://code.claude.com';
const targetUrl = `${baseUrl}/docs/en/changelog`;
const response = await ofetch(targetUrl);
const $: CheerioAPI = load(response);
const items: DataItem[] = $('div.markdown-heading')
.slice(0, limit)
.toArray()
.map((el): DataItem => {
const $heading = $(el);
const version = $heading.find('h2.heading-element').text().trim();
if (!version) {
return null as unknown as DataItem;
}
const descriptionParts: string[] = [];
$heading.nextUntil('div.markdown-heading').each((_, sibling) => {
descriptionParts.push($(sibling).prop('outerHTML') ?? '');
});
const description = descriptionParts.join('');
const anchor = $heading.find('a.anchor').attr('href') ?? `#${version.replaceAll('.', '')}`;
const link = `${targetUrl}${anchor}`;
return {
title: version,
description,
link,
guid: `claude-code-${version}`,
id: `claude-code-${version}`,
};
})
.filter(Boolean);
return {
title: 'Claude Code Changelog',
description: 'Changelog for Claude Code CLI',
link: targetUrl,
item: items,
allowEmpty: true,
};
};
export const route: Route = {
path: '/code/changelog',
name: 'Code Changelog',
url: 'code.claude.com',
maintainers: ['rmaced0'],
handler,
example: '/claude/code/changelog',
categories: ['program-update'],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['code.claude.com/docs/en/changelog'],
target: '/code/changelog',
},
],
};

View File

@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Claude',
url: 'claude.com',
lang: 'en',
};