generated from headllines/hackernews-weekly
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
103 lines (75 loc) · 5.99 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const dayjs = require('dayjs');
const getHeadlines = require('./utils/getHeadlines');
const issue = require('./utils/issue');
const fs = require('fs');
// run every first day of month at 00:01 UTC
const run = async (date) => {
const contents = await getHeadlines(date);
console.log(contents.length);
const res = await issue.open({
owner: 'headllines',
repo: 'hackernews-monthly',
title: `Hacker News Monthly Top 10 @${new Date(date).toISOString().slice(0, 10)}`,
body: contents
});
const issueNumber = res.data.number;
await issue.lock({
owner: 'headllines',
repo: 'hackernews-monthly',
issueNumber,
});
const readmeContent = `
# Hacker News Monthly Top 10 posts
[![](https://badgen.net/badge/icon/RSS/orange?icon=rss&label)](http://rsshub.app/github/issue/headllines/hackernews-monthly)
[![](https://badgen.net/badge/icon/Telegram?icon=telegram&label)](https://t.me/headllines)
[![](https://img.shields.io/github/issues-raw/headllines/hackernews-monthly?label=Issues&logo=github&style=social)](https://github.com/headllines/hackernews-monthly/issues)
[![](https://img.shields.io/github/watchers/headllines/hackernews-monthly?style=social)](https://github.com/headllines/hackernews-monthly/watchers)
[![Follow on Feeds Pub](https://img.shields.io/badge/dynamic/json?label=follow&query=%24.data.feed.followerCount&url=https%3A%2F%2Fapi.feeds.pub%2Fgraphql%3Fquery%3Dquery%2520feed%28%2524id%253A%2520String%21%29%257B%2520feed%28id%253A%2520%2524id%29%2520%257B%2520followerCount%2520%257D%2520%257D%26variables%3D%257B%2522id%2522%253A%2520%2522https%3A%2F%2Frsshub.app%2Fgithub%2Fissue%2Fhead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3/auL/tXY0D0+HO/v6qp+vc3HT7BG2WIV1po+vDJEFhl4P6/4mRDaC5/dfHiKmlhLlCVhvIw5ONtOqb73i0DXGo36UiyD1X1IURPWokgrgXn3+5r3NlHuPzQ/anCcPe8fk0NN60xNWouyxEr4At6pKSUS3QBepYK7U0jGIqr+oxmPBDViJYqKMn1dH+dYP9rsbUqHqrvD84rgf993m3fR+xoSb1AjVktyNDo44qXzTNM1uei/ff7/sfvnbFWvdN8jRG4ZBacKEv5OqyMVtlgtyewTdkmzAybKNHc045ikpxWFxRiiAKJZ7WkGq+lDt1v+u/Q+yaTJXW5e1LL4nXl2rjO7ZFMi+m/DCrEx5IcUq/zCvGbcTHbOUhTh61pNB/DicMxZ+5n0CynuQW4hV0M0xMqiqABLx9I4Ip9Gsz1ejsdLhiV5hr/Z/K2Fo/1r21BYLAyulH8Io9GLgB2wLLQ/ExzWZ5T9Js+aNF0uXdDI8S518Qlaio1P8Q3tKR4IFRfDuokTRYONKKmh3ccDwVmKBieKBieKBgtRHpmCtKLTjp1hZVHkPsbQ9fmK8jlgK4rWWpaXLrqDbT5FK4oqWHUeN300OFE0OFE02KYjU13r7Ob973gA2GXziY5xZwXKE83N/NdF2VifT8mPXHlHXAN6knEFry2pRIfD4XA4usm//qauBcoh1b8AAAAASUVORK5CYII=)](https://feeds.pub/feed/https%3A%2F%2Frsshub.app%2Fgithub%2Fissue%2Fheadllines%2Fhackernews-monthly)
## How to subscribe
Top posts are stored in [issues](https://github.com/headllines/hackernews-monthly/issues). You can subscribe by [watching this repo](#how-does-it-work) or via [RSS](https://feeds.pub/feed/http%3A%2F%2Frsshub.app%2Fgithub%2Fissue%2Fheadllines%2Fhackernews-monthly).
Email and other ways to subscirbe updates are still under development, you can join [the mailing list](https://headllines.com) to get notified.
## How does it work
1. A script fetches top posts on hackernews every day
2. It opens an issue on this repo and store the headlines
3. People can subscribe to new issue via by watching this repo or via [RSS](https://feeds.pub/feed/http%3A%2F%2Frsshub.app%2Fgithub%2Fissue%2Fheadllines%2Fhackernews-monthly)
<img src="https://timqian-imgs.s3.ap-southeast-1.amazonaws.com/2020-09-Screen%20Shot%202020-09-01%20at%205.15.54%20PM.png" alt="hackernews monthly" width="400"/>
## Thanks
- [Algolia](https://hn.algolia.com/) for the hacker news API
- [RSSHub](https://github.com/diygod/rsshub) for generating RSS file from issues
- [Feeds.Pub](https://feeds.pub) for hosting the RSS feed
- [github-trending-repos](https://github.com/vitalets/github-trending-repos) for inspiration
## Related headline collectors
- [Hacker News Daily](https://github.com/headllines/hackernews-daily)
- [Hacker News Weekly](https://github.com/headllines/hackernews-weekly)
## Contribute
We at [headllines.com](https://headllines.com) build open source headline collectors, if you are interested in writing an headline collector and join this orgnization, feel free to join our [telegram group](https://t.me/headllines)
## Sponsors
[琚致远](https://github.com/juzhiyuan) | [Bytebase](https://bytebase.com/) | [Madao](https://madao.me/) | [SecondState](https://bit.ly/3gfWwps)
[Become a sponsor](https://github.com/sponsors/timqian)
## Authors
- [timqian](https://github.com/timqian)
- [leadream](https://github.com/leadream)
> Updated at ${new Date()}
`;
fs.writeFileSync('./README.md', readmeContent, 'utf8');
}
run(new Date())
.catch(err => {throw err});
// const sleep = () => new Promise(res => setTimeout(res, 2000));
// (async function() {
// await run('2020-01-01')
// await sleep();
// await run('2020-02-01')
// await sleep();
// await run('2020-03-01')
// await sleep();
// await run('2020-04-01')
// await sleep();
// await run('2020-05-01')
// await sleep();
// await run('2020-06-01')
// await sleep();
// await run('2020-07-01')
// await sleep();
// await run('2020-08-01')
// })()