diff --git a/docs/design.md b/docs/design.md index 5b35b64762..6e49e3637d 100644 --- a/docs/design.md +++ b/docs/design.md @@ -20,7 +20,7 @@ pageClass: routes ### User Works - + Behance 用户主页 URL 获取用户名,如 的用户名为 `mishapetrick`。 diff --git a/docs/en/design.md b/docs/en/design.md index 7f96898568..ad871e6eb7 100644 --- a/docs/en/design.md +++ b/docs/en/design.md @@ -20,7 +20,7 @@ Some tags are rarely used: `Script`, `direction`, `production`, `design-concep ### User Works - + Behance user's profile URL, like the username will be `mishapetrick`。 diff --git a/lib/router.js b/lib/router.js index 9bd69676dd..8201ef675e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3069,7 +3069,7 @@ router.get('/touhougarakuta/:language/:type', require('./routes/touhougarakuta') router.get('/liequtv/room/:id', require('./routes/liequtv/room')); // Behance -router.get('/behance/:user', require('./routes/behance/index')); +router.get('/behance/:user/:type?', require('./routes/behance/index')); // furstar.jp router.get('/furstar/characters/:lang?', require('./routes/furstar/index')); diff --git a/lib/routes/behance/index.js b/lib/routes/behance/index.js index 13c8262526..0f3806e1e3 100644 --- a/lib/routes/behance/index.js +++ b/lib/routes/behance/index.js @@ -4,9 +4,11 @@ const dayjs = require('dayjs'); module.exports = async (ctx) => { const user = ctx.params.user || ''; + const type = ctx.params.type || 'projects'; + const response = await got({ method: 'get', - url: `https://www.behance.net/${user}/projects`, // 接口只获取12个项目 + url: `https://www.behance.net/${user}/${type}`, // 接口只获取12个项目 headers: { 'X-Requested-With': 'XMLHttpRequest', }, @@ -15,6 +17,9 @@ module.exports = async (ctx) => { const list = data.profile.activeSection.work.projects; const articledata = await Promise.all( list.map(async (item) => { + if (type !== 'projects') { + item = item.project; + } const url = `${item.url}?ilo0=1`; const cache = await ctx.cache.get(url); if (cache) { @@ -38,11 +43,16 @@ module.exports = async (ctx) => { ctx.state.data = { title: `${data.profile.owner.first_name} ${data.profile.owner.last_name}'s Work`, link: `${data.profile.owner.url}`, - item: list.map((item, index) => ({ - title: `${item.name}`, - description: `${articledata[index].content}`, - link: `${item.url}`, - pubDate: dayjs.unix(item.published_on).format(), - })), + item: list.map((item, index) => { + if (type !== 'projects') { + item = item.project; + } + return { + title: `${item.name}`, + description: `${articledata[index].content}`, + link: `${item.url}`, + pubDate: dayjs.unix(item.published_on).format(), + }; + }), }; };