-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpost.html
executable file
·236 lines (216 loc) · 10.3 KB
/
post.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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
{{template "header.html" .}}
{{template "post-readNum.html" .}}
<div id="main-wrapper">
<div id="main">
<div class="row">
<div id="post-wrapper" class="col-12 col-lg-11 col-xl-8">
<div class="post pb-5 pl-1 pr-1 pl-sm-2 pr-sm-2 pl-md-4 pr-md-4 mb-md-4">
<h1 id="post-title" data-toc-skip>{{if .post.Title}} {{.post.Title}} {{else}} Untitled {{end}}</h1>
<div class="post-meta text-muted d-flex flex-column">
<!-- Published date and author -->
<div>
<span>由 </span><span class="semi-bold">{{$.themeInfo.PostAuthor}}</span>
<!-- lastmod -->
<span class="timeago" data-toggle="tooltip" data-placement="bottom" title="{{.post.CreatedTime | datetime}}">发布于 {{dateFormat .post.CreatedTime "2006-01-02"}}</span>
·
<span class="timeago" data-toggle="tooltip" data-placement="bottom" title="{{.post.UpdatedTime | datetime}}">最后更新:{{dateFormat .post.UpdatedTime "2006-01-02"}}</span>
<!-- page views -->
{{ if $.themeInfo.ReadNumType }}
<i class="far fa-eye fa-fw"></i>
{{ if eq $.themeInfo.ReadNumType "Leanote"}}
<span id="pv_{{.Title}}" class="pageviews">{{$.post.ReadNum}}</span>
{{else if eq $.themeInfo.ReadNumType "Leacloud"}}
<span id="{{$.postUrl}}/{{.post.UrlTitle}}" class="leancloud_visitors"><span class="leancloud-visitors-count">1</span></span>
{{end}}
{{end}}
</div>
</div>
<div class="post-content">
<div class="desc {{if $.post.IsMarkdown }}markdown-content{{end}}" id="content">
{{if $.post.IsMarkdown }}
<div id="markdownContent" style="display: none">
<!-- 用textarea装html, 防止得到的值失真 -->
<textarea>{{$.post.Content | raw}}</textarea>
</div> <!-- markdownContent -->
<div style="padding: 20px; text-align: center">
<img src="{{$.themeBaseUrl}}/images/loading-32.gif" />
</div>
{{else}}
{{$.post.Content | raw}}
{{end}}
</div> <!-- #content -->
</div> <!-- post-content -->
<div class="post-tail-wrapper text-muted">
<!-- categories -->
{{ if .post.Cates}}
<div class="post-meta mb-3">
<i class="far fa-folder-open fa-fw mr-1"></i>
{{ range .post.Cates }}
<a href="{{$.cateUrl}}/{{.UrlTitle}}">{{.Title}}</a>
{{ end }}
</div>
{{ end }}
<!-- tags -->
<div class="post-tags">
{{if .post.Tags}}
<i class="fa fa-tags fa-fw mr-1"></i>
<!-- {{blogTags $ .post.Tags}} -->
{{ range $tag := .post.Tags }}
<a href="{{$.tagPostsUrl}}/{{$tag}}" class="post-tag no-text-decoration">{{ $tag }}</a>
{{ end }}
{{end}} <!-- end if -->
</div> <!-- post-tags -->
<!-- license and share -->
<div class="post-tail-bottom d-flex justify-content-between align-items-center mt-3 pt-5 pb-2">
<div class="license-wrapper">
该博客文章由作者通过
<a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>进行授权。
</div>
<!-- sharing -->
{{ template "post-sharing.html" . }}
</div><!-- .post-tail-bottom -->
</div> <!-- post-tail-wrapper -->
</div>
</div> <!-- post-wrapper -->
<div id="panel-wrapper" class="col-xl-3 pl-2 text-muted topbar-down">
{{template "post-update-list-trending-tags.html" .}}
{{template "post-toc.html" .}}
</div> <!-- panel-wrapper -->
</div> <!--end row-->
<div class="row">
<div class="col-12 col-lg-11 col-xl-8">
<div id="post-extend-wrapper" class="pl-1 pr-1 pl-sm-2 pr-sm-2 pl-md-4 pr-md-4">
{{ template "post-nav.html" .}}
{{ template "share_comment.html" .}}
</div>
</div>
</div>
{{template "footer.html" .}}
<!--对应header中的-->
</div> <!--end main-->
</div> <!--end main-wrapper-->
<!--对应header结束-->
{{template "back-to-top.html" .}}
<!-- {{template "mathjax.html" .}} -->
<div id="isPost"></div>
{{if eq $.themeInfo.CDN.Name "jsdelivr"}}
<script>
// var CDN_URL = "{{$.themeInfo.CDN.Url}}";
</script>
<!-- 只有post才需要,从 Header 中移到这里 -->
<!--clibboard-->
<script src="//{{$.themeInfo.CDN.Url}}/npm/clipboard@2/dist/clipboard.min.js"></script>
<!-- Bootstrap-Toc -->
<script src="//{{$.themeInfo.CDN.Url}}/gh/afeld/[email protected]/dist/bootstrap-toc.min.js"></script>
<link rel="stylesheet" href="https://{{$.themeInfo.CDN.Url}}/gh/afeld/[email protected]/dist/bootstrap-toc.min.css">
<!--Mermaid and ChartJs -->
<script src="//{{$.themeInfo.CDN.Url}}/npm/mermaid@8/dist/mermaid.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/npm/chart.js@3/dist/chart.min.js"></script>
<!-- Manific Popup -->
<script src="https://{{$.themeInfo.CDN.Url}}/npm/magnific-popup@1/dist/jquery.magnific-popup.min.js"></script>
<link rel="stylesheet" href="https://{{$.themeInfo.CDN.Url}}/npm/magnific-popup@1/dist/magnific-popup.min.css">
<!-- Prism Highlight -->
<script src="//{{$.themeInfo.CDN.Url}}/npm/[email protected]/prism.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/npm/[email protected]/components.js"></script>
<link rel="stylesheet" href="//{{$.themeInfo.CDN.Url}}/npm/[email protected]/themes/prism.min.css">
<link href="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/google-code-prettify/prettify.min.css" type="text/css" rel="stylesheet"/>
<!-- Katex -->
<script src="https://{{$.themeInfo.CDN.Url}}/npm/[email protected]/dist/katex.min.js"></script>
<link rel="stylesheet" href="https://{{$.themeInfo.CDN.Url}}/npm/[email protected]/dist/katex.min.css">
<!-- Markdown It -->
<script src="//{{$.themeInfo.CDN.Url}}/npm/markdown-it@12/dist/markdown-it.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/markdown-it/plugins/markdown-it-emoji.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/markdown-it/plugins/katex.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/markdown-it/plugins/markdown-it-container.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/markdown-it/plugins/markdown-it-task-lists.min.js"></script>
<script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/markdown-it/plugins/prismjs.js"></script>
{{else}}
<!-- <link href="{{$.prettifyCssUrl}}" type="text/css" rel="stylesheet"/> -->
<!-- <script src="{{$.prettifyJsUrl}}"></script> -->
<!-- BootStrap -->
<script src="/libs/bootstrap/bootstrap-toc.min.js"></script>
<link rel="stylesheet" href="/libs/bootstrap/bootstrap-toc.min.css">
<!-- Prism -->
<script src="/libs/prismjs/prism.min.js"></script>
<script src="/libs/prismjs/components.js"></script>
<link rel="stylesheet" href="/libs/prismjs/prism.min.css">
<link rel="stylesheet" href="/libs/google-code-prettify/prettify.css">
<!-- Manific Popup -->
<script src="/libs/magnific-popup/jquery.magnific-popup.min.js"></script>
<link rel="stylesheet" href="/libs/magnific-popup/magnific-popup.min.css">
<!-- clipboard -->
<script src="/libs/clipboard.min.js"></script>
<!--Mermaid and ChartJs -->
<script src="/libs/chart.min.js"></script>
<script src="/libs/mermaid.min.js"></script>
<!-- Katex -->
<script src="/libs/katex/katex.min.js"></script>
<link rel="stylesheet" href="/libs/katex/katex.min.css">
<!-- Markdown It -->
<script src="/libs/markdown-it/markdown-it.min.js"></script>
<script src="/libs/markdown-it/plugins/markdown-it-emoji.min.js"></script>
<script src="/libs/markdown-it/plugins/katex.js"></script>
<script src="/libs/markdown-it/plugins/markdown-it-container.min.js"></script>
<script src="/libs/markdown-it/plugins/markdown-it-task-lists.min.js"></script>
<script src="/libs/markdown-it/plugins/prismjs.js"></script>
{{end}}
<script src="{{$.themeBaseUrl}}/blog.js"></script>
<link href="{{$.themeBaseUrl}}/prism-dark.css" rel="stylesheet">
<link href="{{$.themeBaseUrl}}/block-container.css" rel="stylesheet">
<!-- markdown 调用markdown来解析得到html -->
{{if $.post.IsMarkdown }}
<!-- <script src="//{{$.themeInfo.CDN.Url}}/gh/ctaoist/[email protected]/public/libs/md2html/md2html_no_escape.min.js"></script> -->
<script>
var content = $.trim($("#markdownContent textarea").val());
var markdownit = window.markdownit({
html: true,
})
.use(window.markdownitEmoji)
// .use(window.markdownitMermaid)
.use(window.markdownitKatex)
.use(window.markdownitPrismjs, {plugins: ['line-numbers', 'code-header']})
.use(window.markdownitTaskLists )
.use(window.markdownitContainer, 'success')
.use(window.markdownitContainer, 'info')
.use(window.markdownitContainer, 'warning')
.use(window.markdownitContainer, 'danger');
document.getElementById('content').innerHTML = markdownit.render(content);
blogPostInit();
// md2Html(content, $("#content"), function(html) {
// blogPostInit();
// $("pre").addClass("prettyprint linenums");
// prettyPrint();
// });
// fix issue https://github.com/afeld/bootstrap-toc/issues/{21,34,35}
// $(document).ready(function () {
// let $toc_ul = $("#toc > ul");
// if ($toc_ul.length) {
// $toc_ul.eq(1).remove(); // 移除生成的第二个目录,从0开始计数
// if ($toc_ul.html().length == 0) { // post没有目录则隐藏
// $("#toc-wrapper").addClass("unloaded");
// }
// }
// });
</script>
<!-- 不是markdown -->
{{else}}
<script>
$(function() {
// weixin();
});
</script>
{{end}}
<script type="text/javascript">
$(document).on('click', 'a', function() {
var target = this.getAttribute('target');
if ( target ) {
return;
}
var href = this.href;
if ( href.indexOf(location.origin) === -1 ) {
this.setAttribute('target', '_blank');
}
});
</script>
</body>
</html>