Use github issue as blog backend

just use this script!

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
#coding:utf-8
import sys
import io
if __name__ == '__main__':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

import json
import requests as req

url = "https://api.github.com/repos/Ph0enixxx/articles/issues"
file_template = """
title: %s

date: %s

tags:
---

%s
"""
cnt = 0

get_text = lambda url :req.get(url).text
get_json = lambda data : json.loads(data)
deal_data = lambda data : [{"title":i["title"].replace(":", ":").replace("[", "【").replace("]", "】"), "content":i["body"], "date":i["created_at"]} for i in data]
def to_file(template): #

def a(i):
with open("./source/_posts/" + str(cnt) + ".md", "w", encoding="utf-8") as fp:
global cnt
print("./source/_posts/" + str(cnt))
fp.write(template%(i['title'], i["date"], i['content']))
fp.close()
cnt += 1
return 233
return a


def main():
a = deal_data(get_json(get_text(url)))
print(a)
wt = to_file(file_template)
[wt(i) for i in a]
# map(wt, a)

main()