共有 17 篇文章
📅 最近更新
2022-07-29
- 2024-09-18
编写
将heimu.css
文件放在themes/archie/assets/css/
文件夹中
1/* heimu.css */
2
3.heimu, .heimu a, a .heimu, .heimu a.new {
4 background-color: #252525;
5 color: #252525;
6 text-shadow: none;
7}
8
9.heimu:hover, .heimu:active,
10.heimu:hover .heimu, .heimu:active .heimu {
11 color: white !important;
12}
13
14.heimu:hover a, a:hover .heimu,
15.heimu:active a, a:active .heimu {
16 color: lightblue !important;
17}
18
19.heimu:hover .new, .heimu .new:hover, .new:hover .heimu,
20.heimu:active .new, .heimu .new:active, .new:active .heimu {
21 color: #BA0000 !important;
22}
编写heimu.html
放在layouts/shortcodes/
文件夹中
2022-07-17
- 2024-09-18
GitHub
https://github.com/gohugoio/hugo.git
Build
- 使用官方编译版本
- 使用源码编译
http://pi.akvicor.com:7021/?p=199
1wget http://pi.akvicor.com:7021/file?f=1233 -O hugo_build.tgz
2tar -zxvf hugo_build.tgz
3cd hugo
4./build.sh
Install
1mv gopath/bin/hugo /usr/bin/hugo
2hugo version
Usage
1# 版本和环境详细信息
2hugo env
3
4# 创建新站点
5hugo new site siteName
6
7# 创建文章
8hugo new index.md
9
10# 编译生成静态文件并输出到public目录
11hugo
12
13# 编译生成静态文件并启动web服务
14hugo server
主题
2022-07-14
- 2024-09-18
为hugo添加搜索功能,在content
下创建search.html
页面,添加以下内容
1+++
2title = "Search"
3description = "Akvico's Blog"
4date = "2022-07-14"
5author = "Akvicor"
6+++
7
8<style>
9 /* 手机适配 */
10 @media screen and (max-width: 500px) {
11 .search{
12 padding-right: 25px;
13 }
14
15 .search input{
16 width: 100%;
17 }
18
19 .search button{
20 display: none;
21 }
22 }
23 /* 电脑适配 */
24 @media screen and (min-width: 500px) {
25 .search{
26 width: 500px;
27 }
28
29 .search input{
30 width: 444px;
31 }
32 }
33
34 /* 通用样式 */
35 .search{
36 margin: auto;
37 }
38
39 .search input{
40 outline: none;
41 border: 2px solid #c05b4d;
42 height: 32px;
43 padding: 10px;
44 }
45 .search button{
46 outline: none;
47 border: 0px;
48 height: 56px;
49 width:56px;
50 position:absolute;
51 background-color:#c05b4d ;
52 }
53 .search .icon{
54 width: 28px;
55 height: 28px;
56 }
57</style>
58<div class="search">
59 <input type="text" placeholder="" id="search-key" />
60 <button onclick="search()">
61 <svg t="1583982313567" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1271"
62 width="200" height="200" xmlns:xlink="http://www.w3.org/1999/xlink">
63 <defs>
64 <style type="text/css"></style>
65 </defs>
66 <path d="M694.857143 475.428571q0-105.714286-75.142857-180.857142T438.857143 219.428571 258 294.571429 182.857143 475.428571t75.142857 180.857143T438.857143 731.428571t180.857143-75.142857T694.857143 475.428571z m292.571428 475.428572q0 29.714286-21.714285 51.428571t-51.428572 21.714286q-30.857143 0-51.428571-21.714286l-196-195.428571q-102.285714 70.857143-228 70.857143-81.714286 0-156.285714-31.714286t-128.571429-85.714286-85.714286-128.571428T36.571429 475.428571t31.714285-156.285714 85.714286-128.571428 128.571429-85.714286T438.857143 73.142857t156.285714 31.714286 128.571429 85.714286 85.714285 128.571428T841.142857 475.428571q0 125.714286-70.857143 228l196 196q21.142857 21.142857 21.142857 51.428572z"
67 p-id="1272" fill="#ffffff"></path>
68 </svg>
69 </button>
70</div>
71<h1 id="search-tip" style="color: #c05b4d;text-align: center;display: none;">Searching ...</h1>
72<br />
73<div id="result"></div>
74
75<script type="text/javascript">
76 // enter
77 window.onload = function() {
78 document.onkeydown = function(ev) {
79 var event = ev || event
80 if (event.keyCode == 13) {
81 search()
82 }
83 }
84 }
85
86 // search
87 function search() {
88 key = document.getElementById("search-key").value;
89 if (key === "") {
90 return;
91 }
92 document.getElementById("search-key").value = "";
93
94 // tip
95 document.getElementById("search-tip").innerText = "Searching ...";
96 document.getElementById("search-tip").style.display = "block";
97
98 // clear
99 var el = document.getElementById('result');
100 var childs = el.childNodes;
101 for (var i = childs.length - 1; i >= 0; i--) {
102 el.removeChild(childs[i]);
103 }
104
105 // xml
106 xmltext = new XMLHttpRequest;
107 xmltext.open("GET", "/index.xml", false);
108 xmltext.send();
109 resp = xmltext.responseXML;
110 items = resp.getElementsByTagName("item");
111 // search
112 var i = 0;
113 haveResult = false;
114 while (i < items.length) {
115 txt = items[i].getElementsByTagName("title")[0].innerHTML + items[i].getElementsByTagName("description")[0].innerHTML
116 if (txt.indexOf(key) > -1) {
117 haveResult = true;
118 title = items[i].getElementsByTagName("title")[0].innerHTML;
119 link = items[i].getElementsByTagName("link")[0].innerHTML;
120 time = items[i].getElementsByTagName("pubDate")[0].innerHTML;
121 mark = items[i].getElementsByTagName("description")[0].innerHTML;
122 addItem(title, link, time, mark)
123 }
124 i++;
125 }
126 if (!haveResult) {
127 document.getElementById("search-tip").innerText = "NULL";
128 document.getElementById("search-tip").style.display = "block";
129 }
130 }
131
132 // add
133 function addItem(title, link, time, mark) {
134 document.getElementById("search-tip").style.display = "none";
135 tmpl = "<article class=\"post\" style=\"border-bottom: 1px solid #e6e6e6;\" >" +
136 "<header class=\"post-header\">" +
137 "<h1 class=\"post-title\"><a class=\"post-link\" href=\"" + link + "\" target=\"_blank\">" + title + "</a></h1>" +
138 "<div class=\"post-meta\">" +
139 " <span class=\"post-time\">" + time + "</span>" +
140 "</div>" +
141 " </header>" +
142 "<div class=\"post-content\">" +
143 "<div class=\"post-summary\">" + mark + "</div>" +
144 "<div class=\"read-more\">" +
145 "<a href=\"" + link + "\" class=\"read-more-link\" target=\"_blank\">Read more</a>" +
146 "</div>" +
147 " </div>" +
148 "</article>"
149 div = document.createElement("div")
150 div.innerHTML = tmpl;
151 document.getElementById('result').appendChild(div)
152 }
153</script>
2022-07-14
- 2024-09-18
编写
编写abbr.html
放在layouts/shortcodes/
文件夹中
1<!-- layouts/shortcodes/abbr.html -->
2<abbr title="{{ .Get "title" }}">{{ .Get "text" }}</abbr>
使用
1{{< abbr title="Ocean University of China" text="OUC" >}}
2021-07-14
- 2024-09-18
如果要启用Mathjax和KaTeX
在header模板中添加以下内容
1 <!-- Mathjax support -->
2 {{ with .Site.Params.mathjax }}
3 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
4
5 <!-- inline Mathjax -->
6 <script type="text/x-mathjax-config">
7 MathJax.Hub.Config({
8 tex2jax: {
9 inlineMath: [['$math_inline$','$math_inline$'], ['\\(','\\)']],
10 displayMath: [['$math_noinline$','$math_noinline$'], ['\[','\]']],
11 processEscapes: true,
12 processEnvironments: true,
13 skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
14 TeX: { equationNumbers: { autoNumber: "AMS" },
15 extensions: ["AMSmath.js", "AMSsymbols.js"] }
16 }
17 });
18 </script>
19 {{ end }}
20
21 <!-- KaTeX support -->
22 {{ with .Site.Params.katex }}
23 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css">
24 <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.js"></script>
25 <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
26
27 <!-- inline KaTeX -->
28 <script>
29 document.addEventListener("DOMContentLoaded", function() {
30 renderMathInElement(document.body, {
31 delimiters: [
32 {left: "$math_noinline$", right: "$math_noinline$", display: true},
33 {left: "$math_inline$", right: "$math_inline$", display: false}
34 ]
35 });
36 });
37 </script>
38 {{ end }}
在layouts/shortcodes下添加latex.html
1<!-- layouts/shortcodes/latex.html -->
2{{ if .Site.Params.viryLatex }}
3 {{ if ne (.Get "inline") ("false") }}
4 {{ $url := printf "<img style='border: none;' src=\"https://latex.akvicor.com/?base=math&key=mTFPk34&crop=1&type=png&transp=1&latex=%s\">" (urlquery .Inner) }}
5 {{ replace $url "+" "%20" | safeHTML }}
6 {{ else }}
7 {{ $url := printf "<p><img style='border: none;' src=\"https://latex.akvicor.com/?base=math&key=mTFPk34&crop=1&type=png&transp=1&latex=%s\"></p>" (urlquery .Inner) }}
8 {{ replace $url "+" "%20" | safeHTML }}
9 {{ end }}
10{{ else }}
11 {{ if ne (.Get "inline") ("false") }}
12 $math_inline${{ .Inner }}$math_inline$
13 {{ else }}
14 $math_noinline${{ .Inner }}$math_noinline$
15 {{ end }}
16{{ end }}
启用
在配置文件中添加