Permalink
Browse files

feat: subdirectory support 网站子目录支持

  • Loading branch information...
MOxFIVE committed Feb 27, 2016
1 parent d9310b5 commit 11db0576ca5ce28c5ef96b0ead38f25e8c3b2614
View
@@ -17,6 +17,11 @@ avatar: /img/avatar.png
# Small icon of Your site | 站点小图标地址
favicon: /favicon.png
# If your site' url is 'http://yoursite.com/blog', set root_url as '/blog/'
# 网站若存放在子目录,请按上面格式填写
# https://hexo.io/docs/configuration.html#URL
root_url:
# Social info. Bar | 社交信息展示
## Keep "mailto:" in Email | 设置 Email 时保留 "mailto:"
## Encrypt email 加密邮件地址 http://ctrlq.org/encode/
@@ -9,7 +9,7 @@
}
else {
var backgroundnum = <%= theme.background_image %>;
var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
var backgroundimg = "url(<%- theme.root_url %>/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
$("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
}
})
View
@@ -26,7 +26,7 @@
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<% if (theme.favicon){ %>
<link rel="icon" href="<%- theme.favicon %>">
<link rel="icon" href="<%- theme.root_url %><%- theme.favicon %>">
<% } %>
<% if (theme.animate){ %>
<%- css('//cdn.bootcss.com/animate.css/3.5.0/animate.min.css') %>
@@ -35,8 +35,8 @@
<link href="//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css" rel="stylesheet">
<% } %>
<%- css('css/style') %>
<link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<%- css('font-awesome/css/font-awesome.min') %>
<link rel="apple-touch-icon" href="<%- theme.root_url %>/apple-touch-icon.png">
<% if (is_home()){ %>
<% if (theme.baidu_site) { %>
<meta name="baidu-site-verification" content="<%- theme.baidu_site %>" />
@@ -46,7 +46,7 @@
<% } %>
<% } %>
<% if (theme.fancybox){ %>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
<%- css('fancybox/jquery.fancybox') %>
<% } %>
<script>
var yiliaConfig = {
@@ -57,7 +57,8 @@
isArchive: <%=is_archive()%>,
isTag: <%=is_tag()%>,
isCategory: <%=is_category()%>,
open_in_new: <%=theme.open_in_new%>
open_in_new: <%=theme.open_in_new%>,
rootUrl: <%=theme.root_url%>,
}
</script>
<% if (theme.baidu_tongji){ %>
@@ -1,11 +1,11 @@
<div class="overlay"></div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="<%=theme.avatar%>" class="animated zoomIn">
<a href="<%- theme.root_url %>" class="profilepic">
<img src="<%- theme.root_url %><%=theme.avatar%>" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/"><%=theme.author%></a></h1>
<h1 class="header-author"><a href="<%- theme.root_url %>"><%=theme.author%></a></h1>
</hgroup>
<% if (theme.subtitle){ %>
@@ -64,7 +64,7 @@
<nav class="header-menu">
<ul>
<% for (var i in theme.menu){ %>
<li><a href="<%- url_for(theme.menu[i]) %>"><%= i %></a></li>
<li><a href="<%- theme.root_url %><%- url_for(theme.menu[i]) %>"><%= i %></a></li>
<%}%>
</ul>
</nav>
@@ -5,11 +5,11 @@
</div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="<%=theme.avatar%>" class="animated zoomIn">
<a href="<%- theme.root_url %>" class="profilepic">
<img src="<%- theme.root_url %><%=theme.avatar%>" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/" title="回到主页"><%=theme.author%></a></h1>
<h1 class="header-author"><a href="<%- theme.root_url %>" title="回到主页"><%=theme.author%></a></h1>
</hgroup>
<% if (theme.subtitle){ %>
<p class="header-subtitle"><%=theme.subtitle%></p>
@@ -37,7 +37,7 @@
content '\f18a'
color transparent
#{name}
background: url('/img/' + name + '.png') center no-repeat color
background: url(root-url + '/img/' + name + '.png') center no-repeat color
// icon from Font Awesome
font-logo = RSS f09e #ef7522,
@@ -67,4 +67,6 @@ left-col-width = hexo-config("left_col_width")px
left-col-color = rgba(255,255,255,.85)
mid-col-color = rgba(255,255,255,.8)
article-color = rgba(255,255,255,.45)
archives-color = rgba(255,255,255,.4)
archives-color = rgba(255,255,255,.4)
root-url = hexo-config("root_url")
@@ -47,7 +47,7 @@
}
var w = target.width();
var h = target.height();
target[0].src = "/img/img-err.png";
target[0].src = yiliaConfig.rootUrl + "/img/img-err.png";
fn();
//todo: 上报
@@ -59,7 +59,7 @@
var t = target.offset().top;
var l = target.offset().left;
var tempDom = target.clone().addClass("lazy-loding").insertBefore(target);
tempDom[0].src = "/img/img-loading.png";
tempDom[0].src = yiliaConfig.rootUrl + "/img/img-loading.png";
target.hide();
}
/**
View
@@ -2,14 +2,14 @@ require([], function (){
var isMobileInit = false;
var loadMobile = function(){
require(['/js/mobile.js'], function(mobile){
require([yiliaConfig.rootUrl + 'js/mobile.js'], function(mobile){
mobile.init();
isMobileInit = true;
});
}
var isPCInit = false;
var loadPC = function(){
require(['/js/pc.js'], function(pc){
require([yiliaConfig.rootUrl + 'js/pc.js'], function(pc){
pc.init();
isPCInit = true;
});
@@ -55,7 +55,7 @@ require([], function (){
//是否使用fancybox
if(yiliaConfig.fancybox === true){
require(['/fancybox/jquery.fancybox.js'], function(pc){
require([yiliaConfig.rootUrl + 'fancybox/jquery.fancybox.js'], function(pc){
var isFancy = $(".isFancy");
if(isFancy.length != 0){
var imgArr = $(".article-inner img");
@@ -72,7 +72,7 @@ require([], function (){
//是否开启动画
if(yiliaConfig.animate === true){
require(['/js/jquery.lazyload.js'], function(){
require([yiliaConfig.rootUrl + 'js/jquery.lazyload.js'], function(){
//avatar
$(".js-avatar").attr("src", $(".js-avatar").attr("lazy-src"));
$(".js-avatar")[0].onload = function(){

1 comment on commit 11db057

@MOxFIVE

This comment has been minimized.

Show comment
Hide comment
@MOxFIVE

MOxFIVE Feb 27, 2016

Owner

Closes #46

Owner

MOxFIVE commented on 11db057 Feb 27, 2016

Closes #46

Please sign in to comment.