diff --git a/docs/picture.md b/docs/picture.md index aace50e1ae..fbc1069b5f 100644 --- a/docs/picture.md +++ b/docs/picture.md @@ -103,3 +103,7 @@ + +## 国家地理 + + diff --git a/lib/router.js b/lib/router.js index 01fcec921b..b76f5bc6e2 100755 --- a/lib/router.js +++ b/lib/router.js @@ -413,6 +413,7 @@ router.get('/sexinsex/:id/:type?', require('./routes/sexinsex/index')); router.get('/gcores/category/:category', require('./routes/gcores/category')); // 国家地理 +router.get('/natgeo/dailyphoto', require('./routes/natgeo/dailyphoto')); router.get('/natgeo/:cat/:type?', require('./routes/natgeo/natgeo')); // 一个 diff --git a/lib/routes/natgeo/dailyphoto.js b/lib/routes/natgeo/dailyphoto.js new file mode 100644 index 0000000000..576789a675 --- /dev/null +++ b/lib/routes/natgeo/dailyphoto.js @@ -0,0 +1,27 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const today = new Date(); + const year = today.getFullYear(); + const month = today.getMonth() + 1; + + const api = `https://www.nationalgeographic.com/content/photography/en_US/photo-of-the-day/_jcr_content/.gallery.${year}-${month}.json`; + const response = await axios.get(api); + const items = response.data.items; + + const out = items.slice(0, 10).map((item) => { + const info = { + title: item.altText, + author: item.credit, + link: item['full-path-url'], + description: `` + item.caption, + }; + return info; + }); + + ctx.state.data = { + title: 'Photo of the Day', + link: 'https://www.nationalgeographic.com/photography/photo-of-the-day/', + item: out, + }; +};