(ctx)
| 43 | }; |
| 44 | |
| 45 | async function handler(ctx) { |
| 46 | const category = ctx.req.param('category') ?? ''; |
| 47 | const subCategory = ctx.req.param('subCategory') ?? ''; |
| 48 | |
| 49 | const rootUrl = 'https://www.30secondsofcode.org'; |
| 50 | const currentUrl = `${rootUrl}${category ? `/${category}` : ''}${subCategory ? `/${subCategory}` : ''}${category || subCategory ? '/p/1/' : ''}`; |
| 51 | |
| 52 | const response = await ofetch(currentUrl); |
| 53 | const $ = load(response); |
| 54 | const heroElement = $('section.hero'); |
| 55 | const heading = heroElement.find('div > h1').text(); |
| 56 | const description = heroElement.find('div > p').text(); |
| 57 | const image = heroElement.find('img').attr('src'); |
| 58 | |
| 59 | const fullList = $('section.preview-list > ul > li').toArray(); |
| 60 | const items = await processList(fullList); |
| 61 | return { |
| 62 | title: heading, |
| 63 | description, |
| 64 | image: `${rootUrl}${image}`, |
| 65 | link: rootUrl, |
| 66 | item: items, |
| 67 | } as Data; |
| 68 | } |
nothing calls this directly
no test coverage detected