diff --git a/docs/design.md b/docs/design.md index f8ebf35a2e..99894fd54e 100755 --- a/docs/design.md +++ b/docs/design.md @@ -4,6 +4,12 @@ pageClass: routes # 设计 +## Blow Studio + +### 主页 + + + ## Axis Studios ### Work type @@ -15,6 +21,7 @@ pageClass: routes 有一些 tag 并不经常使用: `Script`, `direction`, `production`, `design-concept` 等等。 + ## Dribbble ### 流行 diff --git a/docs/en/design.md b/docs/en/design.md index 6c53ce873b..9ad5863176 100755 --- a/docs/en/design.md +++ b/docs/en/design.md @@ -4,6 +4,12 @@ pageClass: routes # Design +## Blow Studio + +### Home + + + ## Axis Studios ### Work type diff --git a/lib/router.js b/lib/router.js index 4feae5240a..f36683bbbb 100755 --- a/lib/router.js +++ b/lib/router.js @@ -2574,6 +2574,9 @@ router.get('/zhuixinfan/list', require('./routes/zhuixinfan/list')); // scoresaber router.get('/scoresaber/user/:id', require('./routes/scoresaber/user')); +// blow-studio +router.get('/blow-studio', require('./routes/blow-studio/work')); + // axis-studios router.get('/axis-studios/:type/:tag?', require('./routes/axis-studios/work')); diff --git a/lib/routes/blow-studio/work.js b/lib/routes/blow-studio/work.js new file mode 100755 index 0000000000..91d7db024f --- /dev/null +++ b/lib/routes/blow-studio/work.js @@ -0,0 +1,71 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: `http://blowstudio.es/work`, + }); + const data = response.data; + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('.portfolios.normal > ul > li').get().slice(0, 10); + const articledata = await Promise.all( + list.map(async (item) => { + const link = `https://www.blowstudio.es${$(item).find('a').attr('href')}`; + + const cache = await ctx.cache.get(link); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const response2 = await got({ + method: 'get', + url: link, + }); + + const articleHtml = response2.data; + const $2 = cheerio.load(articleHtml); + const imglist = $2('div.attachment-grid img').get(); + const mainvideo = $2('.single-page-vimeo-div').attr('data-video-id'); + + const img = imglist.map((item) => ({ + img: $2(item).attr('src'), + })); + const single = { + mainvideo, + describe: $2('div.portfolio-content > div:nth-child(2)').html(), + title: $2('div.portfolio-content > div:nth-child(1)').text(), + images: img, + link: link, + }; + ctx.cache.set(link, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + + ctx.state.data = { + title: 'Blow Studio', + link: 'http://blowstudio.es', + description: $('description').text(), + item: list.map((item, index) => { + let content = ''; + const videostyle = `width="640" height="360"`; + const imgstyle = `style="max-width: 650px; height: auto; object-fit: contain; flex: 0 0 auto;"`; + + content += `
`; + content += `${articledata[index].describe}`; + + if (articledata[index].images) { + for (let p = 0; p < articledata[index].images.length; p++) { + content += `
`; + } + } + + return { + title: `${articledata[index].title}`, + description: `${content}`, + link: `${articledata[index].link}`, + }; + }), + }; +};