-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathdoc.ejs
171 lines (170 loc) Β· 7.8 KB
/
doc.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
166
167
168
169
170
171
<%# Global variables: - page: contain the current page that Hexo is processing.
- pages: contain all the pages pass as a paremeter from docs.ejs %> <% const
toCItems = utils.getToCItems(pages); %>
<article class="content" aria-labelledby="page-heading">
<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="<%= utils.getTargetPagePath(page, 'docs'); %>"
>Documentation</a
>
</li>
<% if (!utils.isGuideIndexPage(page)) { %>
<li>
<a
href="<%= utils.getTargetPagePath(page, 'section'); %>"
class="guide-category"
>
<%= utils.capitalize(page.section); %>
</a>
</li>
<% } %>
<li aria-current="location"><%= page.title %></li>
</ul>
</nav>
<header class="page-intro">
<h1 id="page-heading"><%= page.title %></h1>
<div class="documentation-actions">
<ul>
<li>
<a
target="_blank"
href="<%= `${theme.webhintRepoRoot}/edit/main/${utils.getEditLink(page.originalFile)}` %>"
>Edit</a
>
</li>
</ul>
</div>
</header>
<div class="section" id="main">
<div class="layout layout--sidebar">
<div class="module module--secondary mobile-view">
<ul class="toc-mobile-view">
<li>
<p
role="button"
id="mobile-toc"
aria-controls="mobile-toc-submenu"
aria-expanded="false"
aria-haspopup="true"
class="toc-mobile-view__button expandable"
>
<%= utils.capitalize(page.section); %>
</p>
<ul
role="group"
class="toc-mobile-view__dropdown"
id="mobile-toc-submenu"
hidden
>
<% if (!utils.isGuideIndexPage(page)) { %>
<li class="dropdown__subitem">
<a
href="../<% if (!utils.isSectionIndexPage(page)) { %>../<% } %>"
class="subitem--single"
>Getting Started</a
>
</li>
<% } else { %>
<li class="dropdown__subitem">
<a href="#" class="subitem--single"
>Getting Started</a
>
</li>
<% } %> <%# Using subpages as variable name because
pages is global %> <% toCItems.forEach(({title,
pages: subpages}) => { %>
<li class="dropdown__subitem">
<p><%= utils.capitalize(title); %></p>
<ul>
<%# Using subpage as variable name because
page is global %> <%
subpages.forEach((subpage) => { %>
<li class="subitem">
<a
href="<%= utils.sanitize(subpage.permalink); %>"
><%= subpage.title %></a
>
</li>
<% }); %>
</ul>
</li>
<% }); %>
</ul>
</li>
</ul>
</div>
<div
class="module module--secondary table-of-contents treeview main-view"
role="navigation"
>
<ul role="tree" aria-labelledby="page-heading" tabindex="0">
<% toCItems.forEach(({title, pages: subpages}) => { %>
<li
role="treeitem"
aria-label="subsection"
tabindex="0"
aria-expanded="<% if (page.tocTitle === title) { %>true<% } else { %>false<% } %>"
>
<div
class="<% if (utils.isActiveItem(page, title)) { %> toc-section-title--active <% } else { %> toc-section-title <% } %>"
>
<span class="text"
><%= utils.capitalize(title); %></span
>
<span class="icon"></span>
</div>
<ul role="group">
<% subpages.forEach((subpage) => { %>
<li
role="treeitem"
aria-selected="<% if (page.title === subpage.title) { %>true<% } else { %>false<% } %>"
>
<div
class="<% if(page.title === subpage.title) { %> toc-subsection-title--active <% } else { %> toc-subsection-title <% } %>"
aria-current="<% if (page.title === subpage.title) { %>location<% } %>"
>
<a
class="text"
href="<%= utils.sanitize(subpage.permalink) %>"
tabindex="<% if(page.tocTitle !== title) { %>-1<% } else { %>0<% } %>"
>
<%= subpage.title %>
</a>
</div>
</li>
<% }); %>
</ul>
</li>
<% }); %>
</ul>
</div>
<div class="module module--primary wrap-text">
<%#
Here is where the document content is injected in Hexo.
There is three options right now:
- The real content of the md file. (utils.showMdContent(page))
- Categories index. (page.contentType === 'hints-index')
- Hints index for a category. (page.contentType === 'hints-category')
%>
<% if (utils.showMdContent(page)) { %>
<%- page.content %>
<% } else if (page.contentType === 'hints-index') { %>
<%- include('hints-index', { categories: site.data.categories.categories, utils }); %>
<% } else if (page.contentType === 'hints-category') { %>
<% site.data.categories.categories.forEach((category) => { %>
<% if (category.name === page.title) { %>
<%- include('hints-category', { category }); %>\
<% } %>
<% }); %>
<% } %>
</div>
</div>
<a href="#main" class="anchor-top" hidden aria-label="back to top"
>top</a
>
</div>
</article>