This repository has been archived by the owner on May 26, 2021. It is now read-only.
forked from jonathantneal/mdcss-theme-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.ejs
165 lines (145 loc) · 5.01 KB
/
template.ejs
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><%- opts.title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<% opts.css.forEach(function (href) {
%><link href="<%= href %>" rel="stylesheet"><%
}); %>
<script>examples=<%- JSON.stringify(opts.examples) %>;</script>
<% opts.js.forEach(function (src) {
%><script src="<%= src %>"></script><%
}); %>
</head>
<body>
<header class="masthead" style="background-color: <%= opts.color %>;">
<div class="container">
<a href="/" class="masthead-logo">
<img src="<%= opts.logo %>" alt="<%= opts.title %>" height="32"> <%= opts.title %>
</a>
<nav class="masthead-nav">
<% opts.nav.forEach(function(link) { %>
<a href="<%= link.url %>" target="_blank"><%= link.name %></a>
<% }); %>
</nav>
</div>
</header>
<div class="container">
<div class="columns docs-layout">
<div class="one-fourth column">
<nav class="menu docs-menu">
<% menu(list, 1) %>
</nav>
</div>
<main class="three-fourths column markdown-body">
<% sections(list, 2) %>
</main>
</div>
<footer class="footer">
Last modified <%- lastModified() %>
</footer>
</div>
<script src="prism.js?871234"></script>
<script src="examples.js?873428"></script>
<script src="script.js?02359872"></script>
<script src="anchor.min.js?225234"></script>
<script src="interact.min.js?8552934"></script>
<script>
anchors.options = {
placement: 'left',
visible: 'hover',
class: 'anchor-link'
};
anchors.add('h2, h3');
/* interact('.docs-resize')
* .resizable({
* edges: {
* left: '.c-resize--left',
* right: '.c-resize--right',
* bottom: false,
* top: false
* },
* onmove: function (e) {
* var width = e.rect.width,
* windowWidth = $(window).width();
* if (width < 160) {
* width = 160;
* } else if ((width * 2) + 100 > windowWidth) {
* width = (windowWidth - 100) / 2;
* }
* $('.docs-example').find('docs-resize').addClass('resize-overlay');
* $('.docs-resize').style.width = (width * 2) + 'px';
* },
* onend: function () {
* $('.docs-example').find('docs-resize').removeClass('resize-overlay');
* }
* })
* .on('resizemove', function (event) {
* var target = event.target,
* x = (parseFloat(target.getAttribute('data-x')) || 0);
* // update the element's style
* target.style.width = event.rect.width + 'px';
* // translate when resizing from top or left edges
* x += event.deltaRect.left;
* target.style.webkitTransform = target.style.transform =
* 'translateX(' + x + 'px)';
* target.setAttribute('data-x', x);
* target.textContent = Math.round(event.rect.width);
* });*/
</script>
<% analytics(opts.analytics) %>
</body>
</html>
<%
function analytics(ua) {
%>
<% if (ua) {
%>
<script>
window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;
ga('create','<%- ua %>','auto');ga('send','pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
<%
}
}
function menu(children, depth) {
%>
<% if (depth < 3) children.sort(sort).forEach(function (child) {
if (child.name) {
if (depth < 2) {modifier = "heading";}
if (depth > 1) {modifier = "item";}
%>
<a class="menu-<%- modifier %>" href="#<%- child.name %>"><span><%= child.title %></span></a>
<% if (child.children) menu(child.children, depth + 1) %>
<%
}
}); %>
<%
}
function sections(children, depth) {
depth = Math.max(Math.min(depth, 6), 1);
children.sort(sort).forEach(function (child) {
%>
<section<% if (child.name) { %> id="<%= child.name %>"<% } %>>
<% if (child.title) { %><%- '<h' + (depth - 1) + ' class="page-title">' %><%= child.title %><%- '</h' + (depth - 1) + '>' %><% } %>
<div class="markdown-body">
<%- child.content %>
<% if (child.children) sections(child.children, depth + 1) %>
</div>
</section>
<%
});
}
function lastModified() {
var now = new Date();
var day = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'.split(' ')[now.getDay()];
var month = 'January February March April May June July August September October November December'.split(' ')[now.getMonth()];
return day + ', ' + now.getDate() + ' ' + month + ' ' + now.getFullYear() + ' ' + now.getHours() + ':' + ('0' + now.getMinutes()).slice(-2);
}
function sort(childA, childB) {
return (childA.order || 0) - (childB.order || 0);
}
%>