From 7bdc215e270185f807b87393f3fef2d742597323 Mon Sep 17 00:00:00 2001 From: gavrilov <11378530+gavrilov@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:13:49 -0700 Subject: [PATCH] feat(route): add ollama blog (#15996) * add ollama blog * remove fullText --- lib/routes/ollama/blog.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/routes/ollama/blog.ts diff --git a/lib/routes/ollama/blog.ts b/lib/routes/ollama/blog.ts new file mode 100644 index 000000000..3282274cc --- /dev/null +++ b/lib/routes/ollama/blog.ts @@ -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, + }; +}