Skip to content

Commit

Permalink
docs(core): pubdate, npm ci with templates (DIYgod#7501)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverBehave authored May 8, 2021
1 parent 10f5bb7 commit 9a3ae8a
Show file tree
Hide file tree
Showing 14 changed files with 20,573 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Reference: https://docs.rsshub.app/en/joinus/
- [缓存说明](https://docs.rsshub.app/joinus/#ti-jiao-xin-de-rsshub-gui-ze-bian-xie-jiao-ben-shi-yong-huan-cun) | [How to use cache](https://docs.rsshub.app/joinus/#ti-jiao-xin-de-rsshub-gui-ze-bian-xie-jiao-ben-shi-yong-huan-cun)
- [ ] 目标是否有明显的反爬/频率限制? Is there any sign of anti-bot or rate limit?
- [ ] 如果有, 是否有对应的措施? (延长缓存时间, 写文档说明, etc.) If yes, do your code reflect this sign? (e.g. write documentations, use long cache time)
- [ ] 目标是否有提供日期? Is there a date in the source?
- [ ] 如果有,包是否正确解析? If there is, can this script provide this info?
- [ ] 如果有提供解析能力,时区是否正确调整? Is the timezone correctly provided?
- 如果有提供日期,但是没有提供解析,请说明原因 If there is a date but this script does not parse, please provide your reason.
- [ ] 是否引入的新的包? Any new package introduced?
- 如果有, 请说明原因. If yes, please state your reason
- [ ] 是否使用了`Puppeteer`? Make use of `Puppeteer`?
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
npm-debug.log
error.log
combined.log
package-lock.json
.vscode
.idea
.DS_Store
Expand Down
23 changes: 18 additions & 5 deletions docs/.format/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,24 @@ const loopSideBar = (children, type, lang, prefix) =>
lang,
}));
const loopNav = (nav, lang) =>
nav.map((e) => ({
path: path.resolve(__dirname, '..', e.link.slice(1), 'README.md'),
type: file.NAV_TYPE,
lang,
}));
nav.map((e) => {
if (e.items) {
return loopNav(e.items, lang);
}
if (e.link.endsWith('/')) {
return {
path: path.resolve(__dirname, '..', e.link.slice(1), 'README.md'),
type: file.NAV_TYPE,
lang,
};
} else {
return {
path: path.resolve(__dirname, '..', `${e.link}.md`),
type: file.NAV_TYPE,
lang,
};
}
});
const loopType = (sidebar, lang, prefix) => loopSideBar(sidebar[0].children, file.GUIDE_TYPE, lang, prefix).concat(loopSideBar(sidebar[1].children, file.ROUTE_TYPE, lang, prefix));

/**
Expand Down
38 changes: 2 additions & 36 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,7 @@ module.exports = {
label: '简体中文',
editLinkText: '在 GitHub 上编辑此页',
lastUpdated: '上次更新',
nav: [
{
text: '指南',
link: '/',
},
{
text: '参与我们',
link: '/joinus/',
},
{
text: '部署',
link: '/install/',
},
{
text: '支持 RSSHub',
link: '/support/',
},
],
nav: require('./nav/zh'),
sidebar: {
'/': [
{
Expand Down Expand Up @@ -150,24 +133,7 @@ module.exports = {
label: 'English',
editLinkText: 'Edit this page on GitHub',
lastUpdated: 'Last Updated',
nav: [
{
text: 'Guide',
link: '/en/',
},
{
text: 'Join us',
link: '/en/joinus/',
},
{
text: 'Deploy',
link: '/en/install/',
},
{
text: 'Support RSSHub',
link: '/en/support/',
},
],
nav: require('./nav/en'),
sidebar: {
'/en/': [
{
Expand Down
37 changes: 37 additions & 0 deletions docs/.vuepress/nav/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = [
{
text: 'Guide',
link: '/en/',
},
{
text: 'Join Us',
ariaLabel: 'Join Us',
items: [
{
text: 'Getting Started',
link: '/joinus/quick-start',
},
{
text: 'More details',
items: [
{
text: 'Date Handling',
link: '/joinus/pub-date',
},
{
text: 'Use Cache',
link: '/joinus/use-cache',
},
],
},
],
},
{
text: 'Deploy',
link: '/en/install/',
},
{
text: 'Support RSSHub',
link: '/en/support/',
},
];
37 changes: 37 additions & 0 deletions docs/.vuepress/nav/zh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = [
{
text: '指南',
link: '/',
},
{
text: '参与我们',
ariaLabel: '参与我们',
items: [
{
text: '快速开始',
link: '/joinus/quick-start',
},
{
text: '详细规范',
items: [
{
text: '日期处理',
link: '/joinus/pub-date',
},
{
text: '使用缓存',
link: '/joinus/use-cache',
},
],
},
],
},
{
text: '部署',
link: '/install/',
},
{
text: '支持 RSSHub',
link: '/support/',
},
];
4 changes: 2 additions & 2 deletions docs/en/install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ Execute the following commands to install dependencies
Using `npm`

```bash
$ npm install
$ npm ci
```

Or `yarn`
Or `yarnv1` (not recommended)

```bash
$ yarn
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ $ cd RSSHub
使用 `npm`

```bash
$ npm install --production
$ npm ci --production
```

`yarn`
`yarnv1` (不推荐)

```bash
$ yarn install --production
Expand Down
42 changes: 42 additions & 0 deletions docs/joinus/pub-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 日期处理

在抓取网页的时候,通常情况下网页会提供日期。这篇教程用于说明插件应当如何正确的处理相关情况

## 没有日期

在源没有提供日期的时候,**请勿添加日期**`pubDate`选项应当被留空。

## 规范

`pubDate`接受一个[Date Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)。或者是可以被正确解析的字符串。这里**并不推荐直接返回字符串的方式**,因为其行为可能在不同环境下不一致,[Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)

## 使用工具类

目前,我们推荐使用[dayjs](https://github.com/iamkun/dayjs)进行日期的处理和时区调整。相关工具类有两个:

### Parse Date

这个是一个工具类用于使用[dayjs](https://github.com/iamkun/dayjs)。大部分情况下,应当可以直接使用他获取到正确的`Date Object`

具体解析参数请参考dayjs github说明

```javascript
const parseDate = require('@/utils/parse-date');

const pubDate = parseDate('2020/12/30', 'YYYY/MM/DD')
```


### Timezone

部分网站并不会依据访问者来源进行时区转换,此时获取到的时间是网站本地时间,不一定适合所有RSS订阅者。此时,应当手动指定获取的时间时区:

::: warning 注意
此时,时间将会被转换到服务器时间,方便后续中间件处理。这个是正常流程!
:::

```javascript
const timezone = require('@/utils/timezone');

const pubDate = timezone(new Date(), +8)
```
File renamed without changes.
5 changes: 5 additions & 0 deletions docs/joinus/use-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 使用缓存

部分RSS在生成时需要访问数个页面,这些页面同时并不是很可能经常变化。出于减轻对方服务器压力和节约不必要流量/算力的考虑,这种情况下应当使用缓存。下面是关于缓存工具类的使用场景和具体介绍

<!-- @TODO 在cache类重构后完善 -->
Loading

0 comments on commit 9a3ae8a

Please sign in to comment.