Skip to content

Commit

Permalink
feat: adds academia.edu route DIYgod#12849
Browse files Browse the repository at this point in the history
  • Loading branch information
K33k0 committed May 24, 2024
1 parent f71073d commit d4c3816
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/routes/academiaedu/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'academiaedu',
url: 'https://www.academia.edu/',
};
43 changes: 43 additions & 0 deletions lib/routes/academiaedu/topics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';

export const route: Route = {
path: '/:interest',
radar: [
{
source: ['academia.edu/Documents/in/:interest'],
target: '/:interest',
},
],
name: 'interest',
maintainers: ['k33k0'],
handler,
url: 'academia.edu',
};

async function handler(ctx) {
let items = null
const interest = ctx.req.param('interest');
const response = await ofetch(`https://www.academia.edu/Documents/in/${interest}/MostRecent`);
const $ = load(response);
const list = $('.works > .u-borderBottom1')
.toArray()
.map((item) => {
return {
title: $(item).find('.title > a').first().text(),
link: $(item).find('.title > a').first().attr('href'),
// pubDate
author:$(item).find('span[itemprop=author] > a').text(),
description: $(item).find('.summarized').text()
}
})
return {
// channel title
title: `academia.edu | ${interest} documents`,
// channel link
link: `https://academia.edu/Documents/in/${interest}/MostRecent`,
// each feed item
item: list,
};
}

0 comments on commit d4c3816

Please sign in to comment.