Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route/aimeta): add AI at Meta Blog #17328

Closed
wants to merge 13 commits into from
35 changes: 35 additions & 0 deletions lib/routes/aimeta/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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: ['blog', 'programming'],
canonnizq marked this conversation as resolved.
Show resolved Hide resolved
example: '/meta/blog',
radar: [{ source: ['ai.meta.com/blog'] }],
name: 'Blog',
maintainers: ['gavrilov'],
handler
}

Fixed Show fixed Hide fixed
async function handler() {
const baseUrl = 'https://ai.meta.com';

const response = await ofetch(`${baseUrl}/blog`);
const $ = load(response);

const items = $('div._amsu')
.toArray().map((item) => ({
category: $(item).children('p._amt0').first().text(),
link: $(item).children('a._amt1').first().attr('href'),
title: $(item).children('p._amt2').first().text(),
description: $(item).children('p._amt3').first().text(),
pubDate: parseDate($(item).children('div._amt4').first().text())
}))
return {
Fixed Show fixed Hide fixed
title: 'AI at Meta Blog',
link: 'https://ai.meta.com/blog',
item: items
}
}
Fixed Show fixed Hide fixed
6 changes: 6 additions & 0 deletions lib/routes/aimeta/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
canonnizq marked this conversation as resolved.
Show resolved Hide resolved

export const namespace: Namespace = {
name: 'AI at Meta',
url: 'ai.meta.com',
};
Loading