feat(route): add Smashing magazine (#12961)
* initial commit * feat(route): add Smashing magazine * docs * docs update * add full article * fix docs * docs: spoiler ---------
This commit is contained in:
+53
-1
@@ -506,6 +506,58 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News
|
||||
<RouteEn author="fengkx" example="/scala/blog/posts" path="/scala/blog/:part?" :paramsDesc="['part parmater can be found in the url of blog']" >
|
||||
</RouteEn>
|
||||
|
||||
## Smashing Magazine
|
||||
|
||||
### Articles
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/smashingmagazine" path="/smashingmagazine" radar="1"/>
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/smashingmagazine/react" path="/smashingmagazine/:category?" :paramsDesc="['Find in URL or Table below']" radar="1">
|
||||
|
||||
::: details Category
|
||||
|
||||
| **Category** | |
|
||||
|----------------------|-----------------------|
|
||||
| Accessibility | accessibility |
|
||||
| Best practices | best-practices |
|
||||
| Business | business |
|
||||
| Career | career |
|
||||
| Checklists | checklists |
|
||||
| CSS | css |
|
||||
| Data Visualization | data-visualization |
|
||||
| Design | design |
|
||||
| Design Patterns | design-patterns |
|
||||
| Design Systems | design-systems |
|
||||
| E-Commerce | e-commerce |
|
||||
| Figma | figma |
|
||||
| Freebies | freebies |
|
||||
| HTML | html |
|
||||
| Illustrator | illustrator |
|
||||
| Inspiration | inspiration |
|
||||
| JavaScript | javascript |
|
||||
| Mobile | mobile |
|
||||
| Performance | performance |
|
||||
| Privacy | privacy |
|
||||
| React | react |
|
||||
| Responsive Design | responsive-design |
|
||||
| Round-Ups | round-ups |
|
||||
| SEO | seo |
|
||||
| Typography | typography |
|
||||
| Tools | tools |
|
||||
| UI | ui |
|
||||
| Usability | usability |
|
||||
| UX | ux |
|
||||
| Vue | vue |
|
||||
| Wallpapers | wallpapers |
|
||||
| Web Design | web-design |
|
||||
| Workflow | workflow |
|
||||
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## ui.dev
|
||||
|
||||
### BYTES - Your weekly dose of JS
|
||||
@@ -524,7 +576,7 @@ Stay up to date on the latest React news, tutorials, resources, and more. Delive
|
||||
|
||||
### Visual Studio Code Plugins Marketplace
|
||||
|
||||
<RouteEn author="SeanChao" example="/vscode/marketplace" path="/vscode/marketplace/:category?" :paramsDesc="['Category']">
|
||||
<RouteEn author="SeanChao" example="/vscode/marketplace" path="/vscode/marketplace/:category?" :paramsDesc="['Category']" >
|
||||
|
||||
| Featured | Trending Weekly | Trending Monthly | Trending Daily | Most Popular | Recently Added |
|
||||
| -------- | --------------- | ---------------- | -------------- | ------------ | -------------- |
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category } = ctx.params;
|
||||
const baseUrl = 'https://www.smashingmagazine.com';
|
||||
let route;
|
||||
if (category) {
|
||||
route = `/category/${category}`;
|
||||
} else {
|
||||
route = '/articles';
|
||||
}
|
||||
const { data: response } = await got(`${baseUrl}${route}`);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const listItems = $('article.article--post')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('h2.article--post__title a');
|
||||
const description = item.find('p.article--post__teaser').clone().children().remove().end().text();
|
||||
const author = item.find('span.article--post__author-name a').text();
|
||||
const time = $('p.article--post__teaser time').attr('datetime');
|
||||
const pubDate = parseDate(time, 'YYYY-MM-DD');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: `${baseUrl}${a.attr('href')}`,
|
||||
pubDate,
|
||||
description,
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
listItems.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
item.category = $('li.meta-box--tags a')
|
||||
.toArray()
|
||||
.map((item) => $(item).text());
|
||||
const header = $('div#article__content header.article-header').clone().children('ul').remove().end().html();
|
||||
const summary = $('div#article__content section.article__summary').html();
|
||||
const descr = $('div#article__content div.c-garfield-the-cat')
|
||||
.clone()
|
||||
.children('div')
|
||||
.remove()
|
||||
.end()
|
||||
.toArray()
|
||||
.map((element) => $(element).html());
|
||||
item.description = [header, summary, ...descr].join('');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Smashing Magazine Articles',
|
||||
link: `${baseUrl}${route}`,
|
||||
item: items,
|
||||
description: 'Latest Articles on Smashingmagazine.com',
|
||||
logo: 'https://www.smashingmagazine.com/images/favicon/apple-touch-icon.png',
|
||||
icon: 'https://www.smashingmagazine.com/images/favicon/favicon.svg',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:category?': ['Rjnishant530'],
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'smashingmagazine.com': {
|
||||
_name: 'Smashing Magazine',
|
||||
'.': [
|
||||
{
|
||||
title: 'Articles',
|
||||
docs: 'https://docs.rsshub.app/en/programming.html#a-list-apart',
|
||||
source: ['/articles/'],
|
||||
target: '/smashingmagazine',
|
||||
},
|
||||
{
|
||||
title: 'Category',
|
||||
docs: 'https://docs.rsshub.app/en/programming.html#a-list-apart',
|
||||
source: ['/category/:category'],
|
||||
target: '/smashingmagazine/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:category?', require('./category'));
|
||||
};
|
||||
Reference in New Issue
Block a user