hexo+yilia(在底部)添加
- 網站運行時間:
本站已安全運行 101 天 12 小時 13 分 41 秒
- ICP備案信息:
粵ICP備00000000號
- 設定站點建立時間(年份):
@ 2018 - 2019
1.添加網站運行時間
添加位置建議:如果有統計量(如不蒜子統計量),放在不蒜子後面。沒有就按照下面的建議。
硬性配置
修改\themes\yilia\layout\_partial\footer.ejs
,在</footer>
上面添加如下內容:
<!--《添加網站運行時間 -->
<!--<br/>-->
<span id="timeDate">載入天數...</span><span id="times">載入時分秒...</span>
<script>
var now = new Date();
function createtime() {
var grt = new Date("07/25/2019 12:00:00"); //此處修改你的建站時間或者網站上線時間
now.setTime(now.getTime() + 250);
days = (now - grt) / 1000 / 60 / 60 / 24;
dnum = Math.floor(days);
hours = (now - grt) / 1000 / 60 / 60 - (24 * dnum);
hnum = Math.floor(hours);
if (String(hnum).length == 1) {
hnum = "0" + hnum;
}
minutes = (now - grt) / 1000 / 60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes);
if (String(mnum).length == 1) {
mnum = "0" + mnum;
}
seconds = (now - grt) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds);
if (String(snum).length == 1) {
snum = "0" + snum;
}
document.getElementById("timeDate").innerHTML = " | 本站已安全運行 " + dnum + " 天 ";
document.getElementById("times").innerHTML = hnum + " 小時 " + mnum + " 分 " + snum + " 秒";
}
setInterval("createtime()", 250);
</script>
<!-- 添加網站運行時間》 -->
靈活配置(推薦)
優化上面的內容,設置成可以直接在配置文件中進行開啓和關閉的形式:
1.修改\themes\yilia\_config.yml
,添加如下內容:
# 網站運行時間,格式形如:“本站已安全運行 101 天 12 小時 13 分 41 秒”
# Runing Time
running_time:
enable: true
create_time: '07/25/2019 12:00:00' #此處修改你的建站時間或者網站上線時間
2.修改\themes\yilia\layout\_partial\footer.ejs
,在</footer>
上面添加如下內容:
<!--《添加網站運行時間 <br/>-->
<% if (theme.running_time && theme.running_time.enable && theme.running_time.create_time){ %>
<span id="timeDate">載入天數...</span><span id="times">載入時分秒...</span>
<script>
var now = new Date();
function createtime() {
//此處修改你的建站時間或者網站上線時間
var create_time = '<%- theme.running_time.create_time %>';
now.setTime(now.getTime() + 250);
days = (now - grt) / 1000 / 60 / 60 / 24;
dnum = Math.floor(days);
hours = (now - grt) / 1000 / 60 / 60 - (24 * dnum);
hnum = Math.floor(hours);
if (String(hnum).length == 1) {
hnum = "0" + hnum;
}
minutes = (now - grt) / 1000 / 60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes);
if (String(mnum).length == 1) {
mnum = "0" + mnum;
}
seconds = (now - grt) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds);
if (String(snum).length == 1) {
snum = "0" + snum;
}
document.getElementById("timeDate").innerHTML = " | 本站已安全運行 " + dnum + " 天 ";
document.getElementById("times").innerHTML = hnum + " 小時 " + mnum + " 分 " + snum + " 秒";
}
setInterval("createtime()", 250);
</script>
<% } %>
<!-- 添加網站運行時間》-->
效果
本站已安全運行 101 天 12 小時 13 分 41 秒
2.添加ICP備案信息
添加位置建議:底部第首行。如果有統計量、運行時間前面。沒有就按照下面的建議。
1.修改\themes\yilia\_config.yml
,添加如下內容:
# ICP備案信息(英文全稱:Internet Content Provider,中文全稱:網絡內容提供商。)
# 參考:https://blog.csdn.net/qq_37449342/article/details/95649140
# 粵ICP備00000000號
icp:
enable: true
id: '粵ICP備00000000號' # 備案號
2.修改\themes\yilia\layout\_partial\footer.ejs
,在</footer>
上面添加如下內容:
<!-- 《網站備案號 -->
<% if (theme.icp && theme.icp.enable && theme.icp.id){ %>
<div class="BeiAn-info">
<img src="https://static.dy208.cn/o_1dfilp8ruo521thr1hvf18ji17soa.png" title="備案管理系統">
<a href="http://www.beian.miit.gov.cn/" style="color:#f72b07" target="_blank" title="備案號">
<%- theme.icp.id %>
</a>
</div>
<% } %>
<!-- 網站備案號》 -->
圖標也可爲:http://www.beian.miit.gov.cn/images/top/0.png
效果
3.設定站點建立時間
參考:
- 設定站點建立時間
- https://github.com/MOxFIVE/hexo-theme-yelee/commit/5b8b95628f71bf99b5cea20fa3aadd8ebd7ccc61
這個時間將在站點的底部顯示,如果建站時間小於當前時間(年份),形式爲:@ 2018 - 2019
;否則默認爲當前年份,如:@2019
。
編輯主題的 \themes\yilia\_config.yml
(在hexo根目錄的配置文件中也可以),新增字段 since
。
# Year of Site Creation | 網站成立年份
# 設定站點建立時間,這個時間將在站點的底部顯示,如果是當年顯示爲 @ 2019,否則顯示爲時間段 © 2018 - 2019。
since: 2019
對應的配置文件H:\Hexo\themes\yilia\layout\_partial\footer.ejs
的原內容(部分內容,主要是<div class="footer-left">
標籤內容):
<footer id="footer">
<div class="outer">
<div id="footer-info">
<div class="footer-left">
© <%= date(new Date(), 'YYYY') %> <%= config.author || config.title %>
</div>
<div class="footer-right">
<a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
</div>
</div>
</div>
存在問題:小於時,不能正常顯示(/按照需求顯示)。修改後:
<footer id="footer">
<div class="outer">
<div id="footer-info">
<div class="footer-left">
<!--如果有設置theme.since,並且時間小於當前時間(年份),形式爲:@ 2018 - 2019(+作者/標題);否則默認爲當前年份(+作者/標題)。 -->
<% if (theme.since && !isNaN(theme.since) && theme.since < date(new Date(), 'YYYY')) { %>
© <%- theme.since %>-<%= date(new Date(), 'YYYY') %>
<% } else { %>
© <%= date(new Date(), 'YYYY') %>
<% } %>
<%= config.author || config.title %>
</div>
效果
如:since: 2018
顯示爲@ 2018 - 2019
;否則默認爲當前年份,如:@2019
。