-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
88 lines (79 loc) · 2.65 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
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<title>Remark Viewer</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body {
font-family: 'Lato';
background-color: #343F68;
}
h1, h2, h3 {
font-family: 'Lato', sans-serif;
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.remark-slide-content {
background-color: #343F68;
color: #FF8551;
}
a {
color: #FFDACA;
}
img {
max-width: 570px;
}
</style>
</head>
<body>
<textarea id="source" data-index-url="/" style="visibility: hidden;"></textarea>
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/6.0.1/markdown-it.js"></script>
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js"></script>
<script>
var $source = $('#source');
var baseUrl = $source.attr('data-index-url');
$(function() {
router(window.location.search);
});
function router(location) {
if(!location) {
index();
} else {
renderSlides(location.slice(1));
}
}
function index() {
$.get(baseUrl + 'README.md', function (data) {
var md = window.markdownit();
var tokens = md.parse(data);
var links =
tokens.map(function (token) {
return (token.children || []).filter(function (child) {
return child.type === 'link_open';
});
}).reduce(function (collected, current) {
return collected.concat(current);
}, []);
var $index = $(
links.map(function (link) {
var href = link.attrs[0][1];
var name = href.split('/')[0].replace(/-/g, ' ');
return '<h1><a href="?' + href + '#1">' + name.charAt(0).toUpperCase() + name.slice(1) + '</a></h1>';
}).reduce(function (before, current) {
return before + current;
}, '')
);
$index.insertBefore($source);
});
}
function renderSlides(location) {
$source.load(baseUrl + location, function () {
var slideshow = remark.create({highlightLines: true, highlightSpans: true});
});
}
</script>
</body>
</html>