Skip to content

Commit

Permalink
✨ Feature: add sidebar_display option for controlling the sidebar dis…
Browse files Browse the repository at this point in the history
…play

ISSUES CLOSED: #203
  • Loading branch information
Molunerfinn committed Jan 29, 2020
1 parent e8fbd91 commit 18f22c7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
19 changes: 11 additions & 8 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--- # ---------------
# ---------------
# Theme color for customize
# Notice: color value must in double quotes like "#000" or may cause error!
# ---------------
Expand Down Expand Up @@ -101,8 +101,8 @@ tencent_analytics:
# ---------------
stylesheets:
- /css/index.css
# scripts loaded in the end of the body
# ---------------
# scripts loaded in the end of the body
# ---------------
scripts:
- /js/utils.js
- /js/fancybox.js
Expand All @@ -113,8 +113,8 @@ scripts:
- /js/scroll.js
- /js/head.js

# cdn for third-party library
# ---------------
# cdn for third-party library
# ---------------
cdn:
css:
fontawesome: https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css
Expand Down Expand Up @@ -269,16 +269,19 @@ canvas_ribbon:

# Sidebar Settings
# ---------------
#links_title: Links
#links:
#Name: url
# links_title: Links
# links:
# Name: url

# Follow Me Button
# follow:
# enable: true
# url: ''
# text: ''

# controls the sidebar showing or hidden in different pages
sidebar_display: post # all/index/post/index-none/post-none/hidden

# Ads
# ---------------
# Google Adsense
Expand Down
34 changes: 26 additions & 8 deletions layout/includes/sidebar.pug
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
#sidebar
- const showToc = is_post() && theme.toc.enable
-
let tocNumber
if (page.toc_number !== undefined) tocNumber = page.toc_number
else if (theme.toc.number !== undefined) tocNumber = theme.toc.number
else tocNumber = true
-
- const showToc = is_post() && theme.toc.enable
-
let tocNumber
if (page.toc_number !== undefined) tocNumber = page.toc_number
else if (theme.toc.number !== undefined) tocNumber = theme.toc.number
else tocNumber = true
let currentPageType = is_post()
? 'post'
: is_home()
? 'index'
: 'other'
let display = 'false'
const sidebar_display = theme.sidebar_display || 'post'
if (
currentPageType === sidebar_display ||
(sidebar_display === 'all') ||
(currentPageType !== 'index' && (sidebar_display === 'index-none')) ||
(currentPageType !== 'post' && (sidebar_display === 'post-none'))
) {
display = 'true'
}
if (theme.sidebar_display === 'hidden') {
display = 'false'
}
-
#sidebar(data-display=display)
if(showToc)
.toggle-sidebar-info.text-center
span(data-toggle= _p('sidebar.toggle_article'))= _p('sidebar.toggle_site')
Expand Down
8 changes: 5 additions & 3 deletions source/js/transition.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
$(function () {
// page
$('.layout').velocity('stop')
$('.layout')
.velocity('stop')
.velocity('transition.slideUpIn', {
delay: 500,
duration: 1000,
easing: 'easeInOutQuart',
complete: function () {
if ($('.sidebar-toc').length > 0) {
if ($('#sidebar').data('display')) {
setTimeout(function () {
$('#toggle-sidebar').click()
}, 200)
}
}
})
$('#top-container').velocity('stop')
$('#top-container')
.velocity('stop')
.velocity('transition.fadeIn', {
delay: 500,
duration: 1000,
Expand Down

0 comments on commit 18f22c7

Please sign in to comment.