-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
81 lines (81 loc) · 2.26 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>新闻联播文字稿</title>
<link rel="stylesheet" href="web/github-markdown.min.css">
<script src="web/showdown.min.js"></script>
</head>
<body>
<div id="view" class="markdown-body">加载中...</div>
<style>
html,
body,
.markdown-body {
padding: 0;
border: none;
margin: 0;
height: 100%;
width: 100%;
word-break: break-all;
box-sizing: border-box;
}
.markdown-body {
padding: 1.2em;
overflow: auto;
}
</style>
<script>
fetch(`/news/catalogue.json`).then(response => {
return response.json();
}).then(json => {
render(json);
});
function render(json) {
/*
json: [
{
"date": "20220929"
"abstract": "123\n456"
}
]
*/
let md = `# 《新闻联播》文字稿\n` +
"\n" +
"每日20-22点自动更新当日文字稿\n" +
"\n" +
"开源地址: https://github.com/DuckBurnIncense/xin-wen-lian-bo\n" +
"\n" +
"## 目录: \n" +
"\n";
json.forEach(theNew => {
let date = theNew.date;
let abstract = theNew.abstract.replaceAll("\n", ' ');
md += `- 《新闻联播》 (${date}) [\[查看摘要\]](#${date}) [\[阅读全篇\]](web/view.html?date=${date})\n`;
});
md += `## 新闻摘要\n` +
"\n";
json.forEach(theNew => {
let date = theNew.date;
let abstract = theNew.abstract.replaceAll("\n", ' ');
md += `### [《新闻联播》 (${date})](web/view.html?date=${date}) {${date}}` +
"\n" +
`${abstract}\n` +
"\n" +
`[阅读全文](web/view.html?date=${date})\n` +
"\n" +
"\n";
});
md += `\n© 2022 [DuckBurnIncense](mailto:DuckBurnIncense@outlook.com) 开源地址: [https://github.com/DuckBurnIncense/xin-wen-lian-bo](https://github.com/DuckBurnIncense/xin-wen-lian-bo)\n`
const viewElement = document.getElementById('view');
const converter = new showdown.Converter({
customizedHeaderId: true,
openLinksInNewWindow: true
});
viewElement.innerHTML = converter.makeHtml(md);
}
</script>
</body>
</html>