Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
chore: make catalog a sidebar widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ppoffice committed Mar 11, 2018
1 parent d6369e4 commit 43a43eb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
1 change: 1 addition & 0 deletions _config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ customize:

# Widgets
widgets:
- catalog
- recent_posts
- category
- archive
Expand Down
2 changes: 1 addition & 1 deletion languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ sidebar:
links: 'links'
tags: 'tags'
tag_cloud: 'tag cloud'
catalogue: 'Catalog'
article:
comments: 'Comments'
share: 'Share'
catalogue: 'Table of Contents'
insight:
hint: 'Type something...'
posts: 'Posts'
Expand Down
2 changes: 1 addition & 1 deletion languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ sidebar:
links: '链接'
tags: '标签'
tag_cloud: '标签云'
catalogue: '目录'
article:
comments: '评论'
share: '分享到'
catalogue: '目录'
insight:
hint: '想要查找什么...'
posts: '文章'
Expand Down
6 changes: 0 additions & 6 deletions layout/common/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
<% } %>
<%- partial('post/gallery') %>
<div class="article-entry" itemprop="articleBody">
<% if (post.toc) { %>
<div id="toc" class="toc-article">
<strong class="toc-title"><%= __('article.catalogue') %></strong>
<%- toc(post.content) %>
</div>
<% } %>
<%- post.content %>
</div>
<footer class="article-footer">
Expand Down
2 changes: 1 addition & 1 deletion layout/common/sidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="widgets-container">
<% if (theme.widgets) { %>
<% theme.widgets.forEach(function(widget) { %>
<%- partial('widget/' + widget) %>
<%- partial('widget/' + widget, {post: page}) %>
<% }) %>
<% } %>
</div>
Expand Down
10 changes: 10 additions & 0 deletions layout/widget/catalog.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if (typeof(post) != 'undefined' && post.toc) { %>
<div class="widget-wrap widget-list">
<h3 class="widget-title"><%= __('sidebar.catalogue') %></h3>
<div class="widget">
<div id="toc" class="toc-article">
<%- toc(post.content) %>
</div>
</div>
</div>
<% } %>
14 changes: 0 additions & 14 deletions source/css/_partial/article.styl
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,6 @@ $article-share-link
max-width: 100%
margin: 0 auto

.toc-article
margin-top: 20px
padding: 20px 30px
display: inline-block
background-color: rgba(0,0,0,0.02)
.toc
padding: 0
margin: 10px 0 0
.toc-item
list-style: none
.toc-link
font-size: 0.9em
line-height: 1em


/* right-to-left languages */
.article.rtl
Expand Down
17 changes: 14 additions & 3 deletions source/css/_partial/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@
ul, ol
list-style: none
li
padding: 10px 0
margin: 10px 0
padding-bottom: 10px
font-size: font-size + 1
border-bottom: 1px solid #E4E4E4
&:last-child
margin-bottom: 0px
a
color: color-sidebar-text
&:before
Expand All @@ -167,8 +170,7 @@
list-style: none
li
border: none
&:last-child
padding-bottom: 0px
padding-bottom: 0

.widget-float
a
Expand Down Expand Up @@ -246,3 +248,12 @@
.tagcloud
a
margin-right: 5px

.toc-article
margin: 0
padding: 0
.toc
padding: 0
margin: 10px 0 0
.toc-item
list-style: none

1 comment on commit 43a43eb

@ppoffice
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.