Skip to content

Commit

Permalink
fix(routes/google/research): add description (#18110)
Browse files Browse the repository at this point in the history
  • Loading branch information
cscnk52 authored Jan 13, 2025
1 parent feb1497 commit d69d320
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/routes/google/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import cache from '@/utils/cache';

const baseUrl = 'https://research.google';

Expand All @@ -10,7 +11,7 @@ export const route: Route = {
categories: ['blog'],
example: '/google/research',
name: 'Research Blog',
maintainers: ['Levix'],
maintainers: ['Levix', 'cscnk52'],
radar: [
{
source: ['research.google'],
Expand All @@ -19,7 +20,7 @@ export const route: Route = {
handler: async () => {
const response = await ofetch(`${baseUrl}/blog`);
const $ = load(response);
const items = $('div.js-configurable-list .blog-posts-grid__cards .glue-grid__col')
const list = $('div.js-configurable-list .blog-posts-grid__cards .glue-grid__col')
.toArray()
.map((eleItem) => {
const item = $(eleItem);
Expand All @@ -36,6 +37,17 @@ export const route: Route = {
};
});

const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const response = await ofetch(item.link);
const $ = load(response);
item.description = $('.blog-detail-wrapper.js-gt-blog-detail-wrapper').html();
return item;
})
)
);

return {
title: 'Google Research Blog',
link: `${baseUrl}/blog`,
Expand Down

0 comments on commit d69d320

Please sign in to comment.