-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.ejs
70 lines (65 loc) · 2.46 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
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><%- opts.title %></title>
<meta name="description" content="<%- opts.description %>"/>
<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="c-main-header">
<div class="c-main-header__container">
<img src="<%= opts.logo %>" alt="<%= opts.title %>" class="c-main-header__logo">
<p class="c-main-header__description"><%- opts.description %></p>
</div>
</header>
<div class="c-layout">
<div class="c-layout__sidebar">
<nav class="c-main-nav c-main-header__nav">
<% menu(list, 1) %>
</nav>
</div>
<main class="c-main-content c-layout__main">
<% sections(list, 2) %>
</main>
<%
function menu(children, depth) {
if (depth < 3) { %>
<ul class="c-main-menu c-main-menu--<%= depth %>">
<% children.forEach(function (child) {
if (child.name) { %>
<li class="c-main-menu__item c-main-menu__item--<%= depth %>">
<a href="#<%- child.name %>" class="c-main-menu__link c-main-menu__link--<%= depth %>"><%= child.title %></a>
<% if (child.children) menu(child.children, depth + 1) %>
</li>
<% }
}); %>
</ul>
<% }
}
function sections(children, depth) {
depth = Math.max(Math.min(depth, 6), 1);
children.forEach(function (child) { %>
<section<% if (child.name) { %> id="<%= child.name %>"<% } %> class="c-section">
<% if (child.title) { %><%- '<h' + depth + ' class="c-h' + depth + '">' %><%= child.title %><%- '</h' + depth + '>' %><% } %>
<div class="c-section__inner">
<%- child.content %>
<% if (child.children) sections(child.children, depth + 1) %>
</div>
</section>
<% });
}
%>
<script src="prism.js"></script>
<script src="examples.js"></script>
<script src="script.js"></script>
</body>
</html>