fix(route): ollama library (#16002)
This commit is contained in:
parent
59f8bd4324
commit
9efe96bc88
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue