Skip to content

Commit 718e374

Browse files
authored
fix: claude code changelog query (#21679)
* fix: claude code changelog query * fix: route parseDate rule#13 * fix: cleanup .first() calls
1 parent 25fa127 commit 718e374

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/routes/claude/code-changelog.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Context } from 'hono';
44

55
import type { Data, DataItem, Route } from '@/types';
66
import ofetch from '@/utils/ofetch';
7+
import { parseDate } from '@/utils/parse-date';
78

89
const handler = async (ctx: Context): Promise<Data> => {
910
const limit = Number.parseInt(ctx.req.query('limit') ?? '25', 10);
@@ -14,29 +15,27 @@ const handler = async (ctx: Context): Promise<Data> => {
1415
const response = await ofetch(targetUrl);
1516
const $: CheerioAPI = load(response);
1617

17-
const items: DataItem[] = $('div.markdown-heading')
18+
const items: DataItem[] = $('div.update-container')
1819
.slice(0, limit)
1920
.toArray()
2021
.map((el): DataItem => {
21-
const $heading = $(el);
22-
const version = $heading.find('h2.heading-element').text().trim();
22+
const $entry = $(el);
23+
const version = $entry.find('[data-component-part="update-label"]').text().trim();
2324
if (!version) {
2425
return null as unknown as DataItem;
2526
}
2627

27-
const descriptionParts: string[] = [];
28-
$heading.nextUntil('div.markdown-heading').each((_, sibling) => {
29-
descriptionParts.push($(sibling).prop('outerHTML') ?? '');
30-
});
31-
const description = descriptionParts.join('');
28+
const dateText = $entry.find('[data-component-part="update-description"]').text().trim();
29+
const description = $entry.find('[data-component-part="update-content"]').html() ?? '';
3230

33-
const anchor = $heading.find('a.anchor').attr('href') ?? `#${version.replaceAll('.', '')}`;
34-
const link = `${targetUrl}${anchor}`;
31+
const anchor = $entry.attr('id') ?? version.replaceAll('.', '-');
32+
const link = `${targetUrl}#${anchor}`;
3533

3634
return {
3735
title: version,
3836
description,
3937
link,
38+
pubDate: dateText ? parseDate(dateText) : undefined,
4039
guid: `claude-code-${version}`,
4140
id: `claude-code-${version}`,
4241
};

0 commit comments

Comments
 (0)