Skip to content

Commit

Permalink
Merge pull request #329 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Dec 26, 2024
2 parents 8bc321f + 372904d commit 2851442
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 6 deletions.
63 changes: 63 additions & 0 deletions lib/routes/cursor/changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Route } from '@/types';

import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/changelog',
categories: ['program-update'],
example: '/cursor/changelog',
url: 'www.cursor.com/changelog',
name: 'Changelog',
maintainers: ['p3psi-boo'],
radar: [
{
source: ['www.cursor.com/changelog'],
target: '/cursor/changelog',
},
],
handler,
};

async function handler() {
const url = 'https://www.cursor.com/changelog';

const response = await got({
method: 'get',
url,
});

const $ = load(response.data);

const alist = $('article');

const list = alist.toArray().map((item) => {
const leftSide = item.firstChild! as unknown as Element;
const version = $(leftSide.firstChild!).text();
const dateLabel = $(leftSide.lastChild!).text();
const date = parseDate(dateLabel);

// 从第二个子元素开始到结束都是内容
const content = item.children
.slice(1)
.map((child) => $(child).html())
.join('');
const titleElement = $('h2 a', item);
const link = titleElement.attr('href');
const title = titleElement.text();

return {
title: `${version} - ${title}`,
description: content,
link: `https://www.cursor.com${link}`,
pubDate: date,
};
});

return {
title: 'Cursor Changelog',
link: 'https://www.cursor.com/changelog',
item: list,
};
}
8 changes: 8 additions & 0 deletions lib/routes/cursor/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Cursor',
url: 'www.cursor.com',
description: '',
lang: 'en',
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"tosource": "2.0.0-alpha.3",
"tough-cookie": "5.0.0",
"tsx": "4.19.2",
"twitter-api-v2": "1.18.2",
"twitter-api-v2": "1.19.0",
"ufo": "1.5.4",
"undici": "6.21.0",
"uuid": "11.0.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2851442

Please sign in to comment.