feat(route): add ollama blog (#15996)

* add ollama blog

* remove fullText
This commit is contained in:
gavrilov 2024-06-26 14:13:49 -07:00 committed by GitHub
parent a1322b845d
commit 7bdc215e27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 39 additions and 0 deletions

39
lib/routes/ollama/blog.ts Normal file
View File

@ -0,0 +1,39 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/blog',
categories: ['programming'],
example: '/ollama/blog',
radar: [
{
source: ['ollama.com/blog'],
},
],
name: 'Blog',
maintainers: ['gavrilov'],
handler,
};
async function handler() {
const baseUrl = 'https://ollama.com';
const response = await ofetch(`${baseUrl}/blog`);
const $ = load(response);
const items = $('a.group.border-b.py-10')
.toArray()
.map((item) => ({
title: $(item).children('h2').first().text(),
link: baseUrl + $(item).attr('href'),
pubDate: parseDate($(item).children('h3').first().text()),
description: $(item).children('p').first().text(),
}));
return {
title: 'ollama blog',
link: 'https://ollama.com/blog',
item: items,
};
}