feat: add cohere blog route (#17015)

* feat: add cohere blog route

* Update lib/routes/cohere/index.ts
This commit is contained in:
Loongphy Wei 2024-10-07 22:37:15 +08:00 committed by GitHub
parent ed41cd766a
commit 00d66286f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: ['/blog'],
name: 'Blog',
url: 'cohere.com/blog',
maintainers: ['Loongphy'],
handler,
example: '/cohere/blog',
description: 'Cohere is a platform for building AI applications.',
categories: ['blog'],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['cohere.com'],
},
],
};
async function handler() {
const { posts: data } = await ofetch('https://cohere-ai.ghost.io/ghost/api/content/posts', {
params: {
key: '572d288a9364f8e4186af1d60a',
limit: 'all',
include: ['authors', 'tags'],
filter: 'tag:-hash-hidden+tag:-llmu',
},
});
const items = data.map((item) => ({
title: item.title,
link: 'https://cohere.com/blog/' + item.slug,
description: item.excerpt,
pubDate: parseDate(item.published_at),
author: item.authors.map((author) => author.name).join(', '),
category: item.tags.map((tag) => tag.name),
}));
return {
title: 'The Cohere Blog',
link: 'https://cohere.com/blog',
item: items,
};
}

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Cohere',
url: 'cohere.com',
};