File size: 1,095 Bytes
bf48b89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { load } from 'cheerio';

import type { Data, Route } from '@/types';
import ofetch from '@/utils/ofetch';

import { processList, rootUrl } from './utils';

export const route: Route = {
    path: '/latest',
    categories: ['programming'],
    example: '/latest',
    features: {
        requireConfig: false,
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    radar: [
        {
            source: ['30secondsofcode.org'],
            target: '/latest',
        },
    ],
    name: 'New & Popular Snippets',
    maintainers: ['Rjnishant530'],
    handler,
};

async function handler() {
    const response = await ofetch(rootUrl);

    const $ = load(response);
    const fullList = $('section.preview-list > ul > li').toArray();
    const items = await processList(fullList);
    return {
        title: 'New & Popular Snippets',
        description: 'Discover short code snippets for all your development needs.',
        link: rootUrl,
        item: items,
    } as Data;
}