Skip to content

feat(routes): add cline offcial blog route #18892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions lib/routes/cline/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { Route, DataItem } from '@/types';

const rootUrl = 'https://cline.bot';
const blogUrl = `${rootUrl}/blog`;

// Extract article information from DOM
function extractArticlesFromDOM($) {
return $('article')
.toArray()
.map((article) => {
const element = $(article);
const title = element.find('h2').first().text().trim();
const linkEl = element.find('a').first();
const link = linkEl.attr('href');
const fullLink = link ? (link.startsWith('http') ? link : `${rootUrl}${link.startsWith('/') ? link : `/${link}`}`) : '';

const metaEl = element.find('.text-xs.text-slate-500');
const author = metaEl.find('span').first().text().trim();
const dateStr = metaEl.find('span').eq(2).text().trim();
const pubDate = dateStr ? parseDate(dateStr) : undefined;

const summary = element.find('.text-slate-600').text().trim();
const imgSrc = element.find('img').attr('src') || '';

return {
title,
link: fullLink,
pubDate,
author,
description: `<img src="${imgSrc}" /><p>${summary}</p>`,
};
})
.filter((item) => item.title && item.link);
}

async function handler() {
// Get blog homepage
const response = await got({
method: 'get',
url: blogUrl,
});

const $ = load(response.data);

const articles: DataItem[] = extractArticlesFromDOM($);

if (articles.length === 0) {
throw new Error('No articles found.');
}

return {
title: 'Cline Official Blog',
link: blogUrl,
item: articles,
description: 'Cline Official Blog - AI Coding Assistant',
};
}

export const route: Route = {
path: '/blog',
categories: ['blog'],
example: '/cline/blog',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Blog',
maintainers: ['yeshan333'],
description: 'Cline Official Blog articles',
handler,
url: 'cline.bot/blog',
};
13 changes: 13 additions & 0 deletions lib/routes/cline/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
name: 'Cline Offcial Blog',
url: 'cline.bot',
description: `
Cline Offcial Blog.
Cline is an AI-powered coding assistant that runs in VS Code. It goes beyond simple autocompletion by reading and writing across multiple files, executing commands, and adapting to your workflow—like having a skilled developer pair-programming with you right inside your editor.
Cline understands your codebase context and can help with everything from small code edits to complex refactoring tasks.
`,
zh: {
name: 'Cline Offcial Blog',
description: 'Cline 官方博客',
},
};