Skip to content

Commit

Permalink
修复子目录链接错误问题(#3, #13)及其他bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Dec 15, 2021
1 parent 2573f9b commit 0cdd16e
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cnpm install hexo-theme-webstack -S

### hexo >= 4.0

Copy the `_config.yml` file in the `themes/webstack/` directory to the `rootDir/source/_data/` directory and rename it to `webstack.yml`.
Copy the `_config.example.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`.

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cnpm install hexo-theme-webstack -S

### hexo >= 4.0

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

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

Expand Down
2 changes: 2 additions & 0 deletions _config.yml → _config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ myBlog:
img: /images/logos/myBlog.png
description: 一个懒人的博客。

expand: false

about:
url: /about/
icon: far fa-heart
Expand Down
10 changes: 5 additions & 5 deletions layout/about.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<nav class="navbar horizontal-menu navbar-fixed-top">
<div class="navbar-inner">
<div class="navbar-brand">
<a href="/index.html" class="logo">
<img src="<%= theme.logo.dark %>" width="180px" alt="" class="hidden-xs">
<img src="<%= theme.logo.expanded %>" width="180px" alt="" class="visible-xs">
<a href="<%= url_for('/index.html') %>" class="logo">
<img src="<%= url_for(theme.logo.dark) %>" width="180px" alt="" class="hidden-xs">
<img src="<%= url_for(theme.logo.expanded) %>" width="180px" alt="" class="visible-xs">
</a>
</div>
<div class="navbar-mobile-clear"></div>
Expand Down Expand Up @@ -33,10 +33,10 @@
<h4 class="text-gray"><%= theme.aboutPage.webmaster.head %></h4>
<div class="row">
<div class="col-sm-4">
<div class="xe-widget xe-conversations box2 label-info" onclick="window.open('<%- theme.aboutPage.webmaster.url %>', '_blank')" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<%- theme.aboutPage.webmaster.url %>">
<div class="xe-widget xe-conversations box2 label-info" onclick="window.open('<%- url_for(theme.aboutPage.webmaster.url) %>', '_blank')" data-toggle="tooltip" data-placement="bottom" data-original-title="<%- url_for(theme.aboutPage.webmaster.url) %>">
<div class="xe-comment-entry">
<a class="xe-user-img">
<img src="<%= theme.aboutPage.webmaster.img %>" class="img-circle" width="40">
<img src="<%= url_for(theme.aboutPage.webmaster.img) %>" class="img-circle" width="40">
</a>
<div class="xe-comment">
<a href="#" class="xe-user-name overflowClip_1">
Expand Down
2 changes: 1 addition & 1 deletion layout/common/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
<%- js([setting.js.bootstrap, setting.js.TweenMax, setting.js.resizeable, setting.js.joinable, setting.js.xenonApi, setting.js.xenonToggles, setting.js.xenonCustom]) %>
<% if (setting.busuanzi.enable) { %>
<script async src="<%- setting.js.busuanzi %>"></script>
<script async src="<%- url_for(setting.js.busuanzi) %>"></script>
<% } %>
<% if (page.type!=="about") { %>
<%- js(setting.js.lozad) %>
Expand Down
6 changes: 3 additions & 3 deletions layout/common/group.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div class="row">
<% menus.forEach(function(menu) { %>
<div class="col-sm-3">
<div class="xe-widget xe-conversations box2 label-info" onclick="window.open('<%= menu.url %>', '_blank')" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<%= menu.url %>">
<div class="xe-widget xe-conversations box2 label-info" onclick="window.open('<%= url_for(menu.url) %>', '_blank')" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<%= url_for(menu.url) %>">
<div class="xe-comment-entry">
<a class="xe-user-img">
<img data-src="<%= menu.img %>" class="lozad img-circle" width="40">
<img data-src="<%= url_for(menu.img) %>" class="lozad img-circle" width="40">
</a>
<div class="xe-comment">
<a href="#" class="xe-user-name overflowClip_1">
Expand All @@ -18,4 +18,4 @@
</div>
<% }) %>
</div>
<br />
<br />
2 changes: 1 addition & 1 deletion layout/common/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title><%= setting.tittle || config.title %> - <%= setting.subtitle || config.subtitle %></title>
<meta name="keywords" content="<%= setting.keywords || config.keywords %>">
<meta name="description" content="<%= setting.description || config.description %>">
<link rel="shortcut icon" href="<%= setting.favicon %>">
<link rel="shortcut icon" href="<%= url_for(setting.favicon) %>">
<%- css(Object.values(setting.css)) %>
<%- js(setting.js.jquery) %>
<%- js(setting.js.header) %>
Expand Down
8 changes: 4 additions & 4 deletions layout/common/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div class="sidebar-menu-inner">
<header class="logo-env">
<div class="logo">
<a href="/index.html" class="logo-expanded">
<img src="<%= setting.logo.expanded %>" width="100%" alt="" />
<a href="<%= url_for('/index.html') %>" class="logo-expanded">
<img src="<%= url_for(setting.logo.expanded) %>" width="100%" alt="" />
</a>
<a href="/index.html" class="logo-collapsed">
<img src="<%= setting.logo.collapsed %>" width="40" alt="" />
<a href="<%= url_for('/index.html') %>" class="logo-collapsed">
<img src="<%= url_for(setting.logo.collapsed) %>" width="40" alt="" />
</a>
</div>
<div class="mobile-menu-toggle visible-xs">
Expand Down
12 changes: 6 additions & 6 deletions layout/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
</a>
</li>
<li class="dropdown hover-line language-switcher">
<a href="/index.html" class="dropdown-toggle" data-toggle="dropdown">
<a href="<%= url_for('/index.html') %>" class="dropdown-toggle" data-toggle="dropdown">
<img src="<%- url_for('images/flags/' + setting.flag.icon + '.png') %>" alt="<%= setting.flag.icon %>" /> <%= setting.flag.name %>
</a>
<ul class="dropdown-menu languages">
<li class="active">
<a href="/index.html">
<a href="<%= url_for('/index.html') %>">
<img src="<%- url_for('images/flags/' + setting.flag.icon + '.png') %>" alt="<%= setting.flag.icon %>" alt="<%= setting.flag.icon %>" /> <%= setting.flag.name %>
</a>
</li>
Expand All @@ -41,7 +41,7 @@
<section class="sousuo">
<div class="search">
<div class="search-box">
<span class="search-icon" style="background: url(/images/search_icon.png) 0px 0px; opacity: 1;"></span>
<span class="search-icon" style="background: url(<%= url_for('/images/search_icon.png') %>) 0px 0px; opacity: 1;"></span>
<input type="text" id="txt" class="search-input" autocomplete="off" placeholder="请输入关键字,按回车 / Enter 搜索">
<button class="search-btn" id="search-btn"><i class="fa fa-search"></i></button>
</div>
Expand All @@ -53,13 +53,13 @@
<div class="search-engine" style="display: none;">
<div class="search-engine-head">
<strong class="search-engine-tit">选择您的默认搜索引擎:</strong>
<div class="search-engine-tool">搜索热词: <span id="hot-btn"></span></div>
<div class="search-engine-tool">搜索热词: <span id="hot-btn" style="background-image: url(<%= url_for('/images/off_on.png') %>);"></span></div>
</div>
<ul class="search-engine-list search-engine-list_zmki_ul">
</ul>
</div>
</section>
<script>search()</script>
<script>search('<%= url_for('/images/search_icon.png') %>')</script>
<% } %>
<% if(is_home() || isChildPage){ %>
<% const menuSetting = isChildPage ? page : theme; %>
Expand All @@ -75,7 +75,7 @@
<% const childPath = page.path.replace('index.html', '') + e.config; %>
<% const key = isChildPage?childPath:e.config; %>
<% var menus = site.data && site.data[key] ? site.data[key] : menuSetting[e.config]; %>
<% console.log(page.path,childPath,key); %>
<%# console.log(page.path,childPath,key); %>
<%- partial('common/group.ejs', {e: e, menus: menus || []}); %>
<% } %>
<% }) %>
Expand Down
5 changes: 2 additions & 3 deletions move_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ const fs = require('fs')

if (fs.existsSync('../hexo/package.json')){
const version = JSON.parse(fs.readFileSync('../hexo/package.json')).version
if (version.split('.')[0] === '5') {
if (version.split('.')[0].imcludes('5')) {
const oldConfigPath = '../../source/_data/webstack.yml'
const configPath = '../../_config.webstack.yml'
if (!fs.existsSync(configPath) && !fs.existsSync(oldConfigPath)) {
fs.writeFileSync(configPath, fs.readFileSync('./_config.yml'))
fs.writeFileSync(configPath, fs.readFileSync('./_config.example.yml'))
}
fs.unlinkSync('./_config.yml')
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-webstack",
"version": "2.0.5",
"version": "2.0.6",
"description": "A hexo theme based on webstack.",
"keywords": [
"hexo",
Expand Down
2 changes: 1 addition & 1 deletion source/css/hclonely.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ input::-webkit-input-placeholder{
display: inline-block;
width: 25px;
height: 15px;
background: url('/images/off_on.png') no-repeat 0px 0px;
background-position: 0px 0px;
cursor: pointer
}
.search-engine-tool > span.off{ background-position: -30px 0px }
Expand Down
36 changes: 17 additions & 19 deletions source/js/header.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
function search() {
function search(searchIconUrl) {
$(".search-icon").css("opacity", "1");
var listIndex = -1;
var hotList = 0;
var searchData = {
"thisSearch": "https://www.baidu.com/s?wd=",
"thisSearchIcon": "url('/images/search_icon.png')",
"thisSearchIcon": "url(" + searchIconUrl + ")",
"hotStatus": true,
"data": [{
name: "百度",
img: "url('/images/search_icon.png') -80px 0px",
img: "url(" + searchIconUrl + ") -80px 0px",
position: "0px 0px",
url: "https://www.baidu.com/s?wd="
}, {
name: "谷歌",
img: "url('/images/search_icon.png') -105px 0px",
img: "url(" + searchIconUrl + ") -105px 0px",
position: "-40px 0px",
url: "https://www.google.com/search?q="
}, {
name: "必应",
img: "url('/images/search_icon.png') -80px -25px",
img: "url(" + searchIconUrl + ") -80px -25px",
position: "0px -40px",
url: "https://cn.bing.com/search?q="
}, {
name: "好搜",
img: "url('/images/search_icon.png') -105px -25px",
img: "url(" + searchIconUrl + ") -105px -25px",
position: "-40px -40px",
url: "https://www.so.com/s?q="
}, {
name: "搜狗",
img: "url('/images/search_icon.png') -80px -50px",
img: "url(" + searchIconUrl + ") -80px -50px",
position: "0px -80px",
url: "https://www.sogou.com/web?query="
}, {
name: "淘宝",
img: "url('/images/search_icon.png') -105px -50px",
img: "url(" + searchIconUrl + ") -105px -50px",
position: "-40px -80px",
url: "https://s.taobao.com/search?q="
}, {
name: "京东",
img: "url('/images/search_icon.png') -80px -75px",
img: "url(" + searchIconUrl + ") -80px -75px",
position: "0px -120px",
url: "http://search.jd.com/Search?keyword="
}, {
name: "天猫",
img: "url('/images/search_icon.png') -105px -75px",
img: "url(" + searchIconUrl + ") -105px -75px",
position: "-40px -120px",
url: "https://list.tmall.com/search_product.htm?q="
}, {
name: "1688",
img: "url('/images/search_icon.png') -80px -100px",
img: "url(" + searchIconUrl + ") -80px -100px",
position: "0px -160px",
url: "https://s.1688.com/selloffer/offer_search.htm?keywords="
}, {
name: "知乎",
img: "url('/images/search_icon.png') -105px -100px",
img: "url(" + searchIconUrl + ") -105px -100px",
position: "-40px -160px",
url: "https://www.zhihu.com/search?type=content&q="
}, {
name: "微博",
img: "url('/images/search_icon.png') -80px -125px",
img: "url(" + searchIconUrl + ") -80px -125px",
position: "0px -200px",
url: "https://s.weibo.com/weibo/"
}, {
name: "B站",
img: "url('/images/search_icon.png') -105px -125px",
img: "url(" + searchIconUrl + ") -105px -125px",
position: "-40px -200px",
url: "http://search.bilibili.com/all?keyword="
}, {
name: "豆瓣",
img: "url('/images/search_icon.png') -80px -150px",
img: "url(" + searchIconUrl + ") -80px -150px",
position: "0px -240px",
url: "https://www.douban.com/search?source=suggest&q="
}, {
name: "优酷",
img: "url('/images/search_icon.png') -105px -150px",
img: "url(" + searchIconUrl + ") -105px -150px",
position: "-40px -240px",
url: "https://so.youku.com/search_video/q_"
}, {
name: "GitHub",
img: "url('/images/search_icon.png') -80px -175px",
img: "url(" + searchIconUrl + ") -80px -175px",
position: "0px -280px",
url: "https://github.com/search?utf8=✓&q="
}]
Expand Down Expand Up @@ -243,10 +243,8 @@ function switchNightMode() {
if (night == '0') {
document.body.classList.add('night');
document.cookie = "night=1;path=/"
console.log(' ');
} else {
document.body.classList.remove('night');
document.cookie = "night=0;path=/"
console.log(' ');
}
}

0 comments on commit 0cdd16e

Please sign in to comment.