Browse Source

add profile visibility config

ppoffice 10 years ago
parent
commit
a38a10761f
5 changed files with 35 additions and 21 deletions
  1. 2 0
      layout/_partial/header.ejs
  2. 4 2
      layout/layout.ejs
  3. 20 6
      source/css/_variables.styl
  4. 8 12
      source/css/style.styl
  5. 1 1
      source/js/script.js

+ 2 - 0
layout/_partial/header.ejs

@@ -7,11 +7,13 @@
           <a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
         <% } %>
       </nav>
+      <% if(theme.profile) { %>
       <nav id="sub-nav">
         <div class="profile" id="profile-nav">
           <a id="profile-anchor" href="javascript:;"><img class="avatar" src="<%- url_for(config.avatar) %>"><i class="fa fa-caret-down"></i></a>
         </div>
       </nav>
+      <% } %>
       <div id="search-form-wrap">
         <%- search_form({button: ' '}) %>
       </div>

+ 4 - 2
layout/layout.ejs

@@ -3,9 +3,11 @@
   <div id="container">
     <%- partial('_partial/header') %>
     <div class="outer">
-      <%- partial('_partial/profile', null, {cache: !config.relative_link}) %>
+      <% if (theme.profile){ %>
+        <%- partial('_partial/profile', null, {cache: !config.relative_link}) %>
+      <% } %>
       <section id="main"><%- body %></section>
-      <% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
+      <% if (theme.sidebar){ %>
         <%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
       <% } %>
     </div>

+ 20 - 6
source/css/_variables.styl

@@ -36,28 +36,42 @@ logo-url = "images/logo.png"
 sidebar = hexo-config("sidebar")
 thumbnail-default-small = 'images/thumb-default-small.png'
 
-// Profile
+// Profile bar
+profile = hexo-config("profile")
 profile-avatar-size = 128px
 
 // Layout
 block-margin = 40px
 article-padding = 20px
 mobile-nav-width = 280px
-profile-column = 3
+main-column = 7
 sidebar-column = 3
+profile-column = 3
 sidebar-column-tablet = 4
-main-column = 7
-main-column-tablet = 9
 
-if sidebar and sidebar isnt bottom
+if sidebar
   _sidebar-column = sidebar-column
 else
   _sidebar-column = 0
 
+if profile
+  _profile-column = profile-column
+else
+  _profile-column = 0
+
 // Grids
 column-width = 80px
 gutter-width = 20px
-columns = main-column + _sidebar-column + profile-column
+if _sidebar-column is 0 and _profile-column is 0
+  columns = 10
+  main-column = 10
+else
+  columns = main-column + _sidebar-column + _profile-column
+
+if sidebar
+  main-column-tablet = 6
+  if profile
+    main-column-tablet = 9
 
 // Media queries
 mq-mini = "screen and (max-width: 559px)"

+ 8 - 12
source/css/style.styl

@@ -34,10 +34,6 @@ a
   padding: 0 gutter-width
   @media mq-mini
     padding: 0
-    
-
-.inner
-  column(columns)
 
 .left, .alignleft
   float: left
@@ -57,12 +53,14 @@ a
   & > .outer
     margin-bottom: 30px
 
-if sidebar and sidebar isnt bottom
-  #main
-    @media mq-normal
-      column(main-column)
-    @media mq-tablet
+#main
+  @media mq-normal
+    column(main-column)
+  @media mq-tablet
+    if sidebar
       column(main-column-tablet)
+    else
+      width: 100%
 
 @import "_extend"
 @import "_partial/header"
@@ -73,9 +71,7 @@ if sidebar and sidebar isnt bottom
 @import "_partial/footer"
 @import "_partial/highlight"
 @import "_partial/mobile"
-
-if sidebar
-  @import "_partial/sidebar"
+@import "_partial/sidebar"
 
 if sidebar is left
   #main

+ 1 - 1
source/js/script.js

@@ -1,5 +1,5 @@
 (function($){
-  var toTop = $('#toTop').offset().top - $(window).height() + 20;
+  var toTop = $('#toTop').length ? $('#toTop').offset().top - $(window).height() + 20 : 0;
 
   // Share
   $('body').on('click', function(){