mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
* Add(route): add Google Fonts and change to V2 * Fix(route): added throw error when API key is underfined * Fix(docs): add warning container * Fix(docs): Update docs/design.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(route): sort routes * Fix(route): Update lib/v2/google/fonts.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
const got = require('@/utils/got');
|
|
|
|
module.exports = async (ctx) => {
|
|
const { language = 'zh-CN' } = ctx.params;
|
|
const current = new Date();
|
|
const year = current.getFullYear();
|
|
const month = current.getMonth() + 1;
|
|
const link = `https://www.google.com/doodles?hl=${language}`;
|
|
|
|
const { data } = await got({
|
|
method: 'get',
|
|
url: `https://www.google.com/doodles/json/${year}/${month}?hl=${language}`,
|
|
headers: {
|
|
Referer: link,
|
|
},
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title: 'Google Doodles',
|
|
link,
|
|
item:
|
|
data &&
|
|
data.map((item) => {
|
|
const date = `${item.run_date_array[0]}-${item.run_date_array[1]}-${item.run_date_array[2]}`;
|
|
|
|
return {
|
|
title: item.title,
|
|
description: `<img src="https:${item.url}" /><br>${item.share_text}`,
|
|
pubDate: new Date(date).toUTCString(),
|
|
guid: item.url,
|
|
link: `https://www.google.com/search?q=${encodeURIComponent(item.query)}`,
|
|
};
|
|
}),
|
|
};
|
|
};
|