diff --git a/lib/routes/ollama/models.ts b/lib/routes/ollama/models.ts index 335fe4042..3e6b4aedf 100644 --- a/lib/routes/ollama/models.ts +++ b/lib/routes/ollama/models.ts @@ -1,6 +1,7 @@ import { Route } from '@/types'; import ofetch from '@/utils/ofetch'; import { load } from 'cheerio'; +import { parseRelativeDate } from '@/utils/parse-date'; export const route: Route = { path: '/library', @@ -12,23 +13,25 @@ export const route: Route = { }, ], name: 'Models', - maintainers: ['Nick22nd'], + maintainers: ['Nick22nd', 'gavrilov'], handler, }; async function handler() { - const response = await ofetch('https://ollama.com/library'); + const response = await ofetch('https://ollama.com/library?sort=newest'); const $ = load(response); const items = $('#repo > ul > li > a') .toArray() .map((item) => { - const name = $(item).children('h2').first(); + const name = $(item).find('h2 span').first(); const link = $(item).attr('href'); - const description = $(item).children('p').first(); + const description = $(item).find('div p.break-words').first(); + const pubDate = $(item).find('span:contains("Updated")').first(); return { title: name.text(), link, description: description.text(), + pubDate: parseRelativeDate(pubDate.text()), }; }); return {