Skip to content

Commit

Permalink
添加搜索功能,统计功能及自定义html功能
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jun 25, 2020
1 parent dad6b18 commit d47606b
Show file tree
Hide file tree
Showing 16 changed files with 920 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.vscode
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ git clone https://github.com/HCLonely/hexo-theme-webstack themes/webstack

## Configuration

Copy the `_config.yml` file in the `themes/webstack/` directory to the `rootDir/source/_data/` directory and rename it to `webstack.yml`.

Configure it by editing `webstack.yml`.

### favicon

> Website icon.
Expand Down Expand Up @@ -57,7 +61,7 @@ logo:

Examples:
```yml
flag:
flag:
icon: flag-cn
name: Chinese
```
Expand Down Expand Up @@ -158,7 +162,7 @@ type: 'about'
Examples:
```yml
aboutPage:
website:
website:
head: 关于本站
html: '<blockquote><p>本站是hexo主题<a href="https://github.com/HCLonely/hexo-theme-webstack">hexo-theme-webstack</a>的demo站。</p></blockquote>'
webmaster:
Expand All @@ -170,6 +174,42 @@ aboutPage:
html: '<br /><blockquote><p>本站是<a href="https://github.com/HCLonely">HCLonely</a>基于<a href="https://github.com/WebStackPage/WebStackPage.github.io">WebStackPage</a>项目做的一款<a href="https://hexo.io/">Hexo</a>主题。</p></blockquote>'
```

### busuanzi

> Website statistics by busuanzi.

- enable: Whether to enable this feature.
- position: The number of visits is displayed, `footer` is displayed in the footer, and `sidebar` is displayed in the sidebar.
- pv: The number of visits displayed by the traffic, `$pv` will be replaced by the number of visits.
- uv: The number of visitors displayed, `$uv` will be replaced by the number of visitors.

Examples:
```yml
busuanzi:
enable: true
position: sidebar
pv: 本站总访问量$pv
uv: 本站总访客数$uv
```

### custom

> Customize `html` content.

- head: Content inserted into the `<head></head>` tag.
- body: Content inserted before the `</body>` tag.

Examples:
```yml
custom:
head: |- # The following content is inserted into the <head></head> tag, you can set up multiple lines, pay attention to at least four spaces at the beginning of each line.
<link rel="stylesheet" type="text/css" href="custom.css">
<script src="custom.js"></script>
body: |- # Insert the following content before the </body> tag, you can set multiple lines, pay attention to at least four spaces at the beginning of each line.
<div>custom text</div>
<script src="custom.js"></script>
```

## config

> [Main] Website content settings
Expand Down
46 changes: 43 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ git clone https://github.com/HCLonely/hexo-theme-webstack themes/webstack

## 配置

`themes/webstack/`目录内的`_config.yml`文件复制到`博客根目录/source/_data/`目录内,并重命名为`webstack.yml`.

通过编辑`webstack.yml`进行配置。

### favicon

> 网站图标
Expand Down Expand Up @@ -55,7 +59,7 @@ logo:

示例:
```yml
flag:
flag:
icon: flag-cn
name: Chinese
```
Expand Down Expand Up @@ -156,7 +160,7 @@ type: 'about'
示例:
```yml
aboutPage:
website:
website:
head: 关于本站
html: '<blockquote><p>本站是hexo主题<a href="https://github.com/HCLonely/hexo-theme-webstack">hexo-theme-webstack</a>的demo站。</p></blockquote>'
webmaster:
Expand All @@ -168,6 +172,42 @@ aboutPage:
html: '<br /><blockquote><p>本站是<a href="https://github.com/HCLonely">HCLonely</a>基于<a href="https://github.com/WebStackPage/WebStackPage.github.io">WebStackPage</a>项目做的一款<a href="https://hexo.io/">Hexo</a>主题。</p></blockquote>'
```
### busuanzi
> 不蒜子统计
- enable: 是否启用不蒜子统计
- position: 访问量显示位置, `footer`显示在页脚, `sidebar`显示在侧边栏
- pv: 访问量显示的内容, `$pv`会被替换为访问量
- uv: 访客数显示的内容, `$uv`会被替换为访客数

示例:
```yml
busuanzi:
enable: true
position: sidebar
pv: 本站总访问量$pv
uv: 本站总访客数$uv
```

### custom

> 自定义`html`内容

- head: 插入到`<head></head>`标签内的内容
- body: 插入到`</body>`标签之前的内容

示例:
```yml
custom:
head: |- # 以下内容插入到<head></head>标签内,可设置多行,注意每行开头至少四个空格
<link rel="stylesheet" type="text/css" href="custom.css">
<script src="custom.js"></script>
body: |- # 以下内容插入到</body>标签之前,可设置多行,注意每行开头至少四个空格
<div>custom text</div>
<script src="custom.js"></script>
```

## config

> [主要]网站内容设置
Expand Down Expand Up @@ -224,6 +264,6 @@ hotTools:
description: 面向开源及私有软件项目的托管平台。
```

以上两种方式任选一种即可,建议使用第二种。
> 以上两种方式任选一种即可,建议使用第二种。

[配置详情](https://blog.hclonely.com/posts/3cd4fb34/)
17 changes: 17 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,23 @@ aboutPage:

since: 2020

busuanzi:
enable: true
position: sidebar # 'footer','sidebar'
pv: 本站总访问量$pv
uv: 本站总访客数$uv

custom:
head: |- # 以下内容插入到<head></head>标签内,可设置多行,注意每行开头至少四个空格
<!-- 直接添加html内容即可 -->
<!-- 可设置多行 -->
body: |- # 以下内容插入到</body>标签之前,可设置多行,注意每行开头至少四个空格
<!-- 直接添加html内容即可 -->
<!-- 可设置多行 -->
js:
header: /js/header.js
footer: /js/footer.js
jquery: /js/jquery-1.11.1.min.js
bootstrap: /js/bootstrap.min.js
TweenMax: /js/TweenMax.min.js
Expand All @@ -93,6 +109,7 @@ js:
respond: /js/respond.min.js

css:
hclonely: /css/hclonely.css
fonts: //fonts.loli.net/css?family=Arimo:400,700,400italic
linecons: /css/fonts/linecons/css/linecons.min.css
fontawesome: /css/fonts/fontawesome/css/all.min.css
Expand Down
13 changes: 11 additions & 2 deletions layout/common/footer.ejs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<footer class="main-footer sticky footer-type-1">
<div class="footer-inner">
<!-- Add your copyright text here -->
<p class="footer-text">
<p>
<% var now = new Date().getFullYear(); %>
&copy; <%- theme.since === now ? theme.since : (theme.since + " - " + now) %>
<a href="<%= theme.about.url %>"><strong>WebStack</strong></a> design by <a href="http://viggoz.com" target="_blank"><strong>Viggo</strong></a> | Power by <a href="https://hexo.io/" target="_blank"><strong>Hexo</strong></a> & <a href="https://github.com/HCLonely/hexo-theme-webstack/" target="_blank"><strong>hexo-theme-webstack</strong></a>
</p>
<% if (theme.busuanzi.enable && theme.busuanzi.position === 'footer') { %>
<p>
<span id="busuanzi_container_site_pv"><%- theme.busuanzi.pv.replace(/\$pv/i,'<span id="busuanzi_value_site_pv"></span>') %></span> |
<span id="busuanzi_container_site_uv"><%- theme.busuanzi.uv.replace(/\$uv/i,'<span id="busuanzi_value_site_uv"></span>') %></span>
</p>
<% } %>
<div class="go-up">
<a href="#" rel="go-top">
<i class="fas fa-angle-up"></i>
Expand All @@ -16,8 +22,11 @@
</div>
</div>
<%- js([theme.js.bootstrap, theme.js.TweenMax, theme.js.resizeable, theme.js.joinable, theme.js.xenonApi, theme.js.xenonToggles, theme.js.xenonCustom]) %>
<% if (theme.busuanzi.enable) { %>
<script async src="<%- theme.js.busuanzi %>"></script>
<% } %>
<% if (is_home()) { %>
<%- js(theme.js.lozad) %>
<% } else { %>
<textarea tabindex="-1" style="position: absolute; top: -999px; left: 0px; right: auto; bottom: auto; border: 0px; padding: 0px; box-sizing: content-box; word-wrap: break-word; overflow: hidden; transition: none; height: 0px !important; min-height: 0px !important; font-family: Arimo, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: 400; font-style: normal; letter-spacing: 0px; text-transform: none; word-spacing: 0px; text-indent: 0px; line-height: 18.5714px; width: 53px;" class="autosizejs" id="autosizejs"></textarea>
<% } %>
<% } %>
6 changes: 5 additions & 1 deletion layout/common/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="shortcut icon" href="<%= theme.favicon %>">
<%- css(Object.values(theme.css)) %>
<%- js(theme.js.jquery) %>
<%- js(theme.js.header) %>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<%- js(theme.js.html5shiv) %>
Expand All @@ -30,4 +31,7 @@
<% if (theme.banner) { %>
<meta name="twitter:image" content="<%= theme.banner %>">
<% } %>
</head>
<% if (theme.custom && theme.custom.head) { %>
<%- theme.custom.head %>
<% } %>
</head>
54 changes: 34 additions & 20 deletions layout/common/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<header class="logo-env">
<div class="logo">
<a href="/index.html" class="logo-expanded">
<img src="<%= theme.logo.expanded %>" width="100%" alt="" />
<img src="<%= theme.logo.expanded %>" width="100%" alt="" />
</a>
<a href="/index.html" class="logo-collapsed">
<img src="<%= theme.logo.collapsed %>" width="40" alt="" />
Expand All @@ -23,24 +23,24 @@
<li>
<% if (e.submenu) { %>
<a class="fas fa-angle-down" style="cursor: pointer;">
<% } else { %>
<a href="#<%= e.name %>" class="smooth">
<% } %>
<i class="<%= e.icon %>"></i>
<span class="title"><%= e.name %></span>
</a>
<% if (e.submenu) { %>
<ul>
<% e.submenu.forEach(function(e) { %>
<li>
<a href="#<%= e.name %>" class="smooth">
<i class="<%= e.icon %>"></i>
<span class="title"><%= e.name %></span>
</a>
</li>
<% }) %>
</ul>
<% } %>
<% } else { %>
<a href="#<%= e.name %>" class="smooth">
<% } %>
<i class="<%= e.icon %>"></i>
<span class="title"><%= e.name %></span>
</a>
<% if (e.submenu) { %>
<ul>
<% e.submenu.forEach(function(e) { %>
<li>
<a href="#<%= e.name %>" class="smooth">
<i class="<%= e.icon %>"></i>
<span class="title"><%= e.name %></span>
</a>
</li>
<% }) %>
</ul>
<% } %>
</li>
<% } %>
<% if (theme.about) { %>
Expand All @@ -51,6 +51,20 @@
</a>
</li>
<% } %>
<% if (theme.busuanzi.enable && theme.busuanzi.position === 'sidebar') { %>
<li>
<a href="javascript:void(0)">
<i class="fas fa-eye"></i>
<span id="busuanzi_container_site_pv"><%- theme.busuanzi.pv.replace(/\$pv/i,'<span id="busuanzi_value_site_pv"></span>') %></span>
</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="fas fa-users"></i>
<span id="busuanzi_container_site_uv"><%- theme.busuanzi.uv.replace(/\$uv/i,'<span id="busuanzi_value_site_uv"></span>') %></span>
</a>
</li>
<% } %>
</ul>
</div>
</div>
</div>
Loading

0 comments on commit d47606b

Please sign in to comment.