From 2d9392535e0bedc63baa71212ce558951c3f252d Mon Sep 17 00:00:00 2001 From: "parsiya@gmail.com" Date: Sat, 9 Apr 2016 21:19:30 -0400 Subject: Make Recent Posts section in sidebar optional. Fixes #12. --- README.md | 6 +++--- layouts/partials/sidebar.html | 31 ++++++++++++++----------------- sample-config.toml | 4 ++-- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7c61364..d6b5f3f 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ post = "/blog/:year-:month-:day-:title/" [params] - # number of recent posts that will be shown in the sidebar - default is 5 - SidebarRecentLimit = 5 + # number of recent posts that will be shown in the sidebar - set to 0 or remove to hide this section + sidebarRecentLimit = 10 # sidebar customization - passed to markdownify sidebar_header = "Sidebar Header" @@ -242,7 +242,7 @@ This menu can be enabled by setting the `sidebar_menu_enabled` to `true` in conf weight = 1 ### Recent posts -Last x recent posts can be displayed in the sidebar. This number can be set in the config file using the `SidebarRecentLimit`. If this number is not set, last five posts will be displayed. +Last x recent posts can be displayed in the sidebar. This number can be set in the config file using the `sidebarRecentLimit`. To hide this section either remove `sidebarRecentLimit` from the config file or set it to zero. ## Shortcodes Creating [shortcodes](https://gohugo.io/extras/shortcodes/) in Hugo was surprisingly easy. I used two plugins in Octopress that I re-created in Hugo using shortcodes. They add captions to code blocks and images. These shortcodes are located at `hugo-octopress/layouts/shortcodes/`. diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 51085dd..9ba3904 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -64,22 +64,19 @@ {{ end }} - -
-

Recent Posts

- - - -
+ + + {{ if not (eq .Site.Params.sidebarRecentLimit 0) }} +
+

Recent Posts

+ +
+ {{ end }} diff --git a/sample-config.toml b/sample-config.toml index 290813d..6943e6d 100644 --- a/sample-config.toml +++ b/sample-config.toml @@ -65,8 +65,8 @@ post = "/blog/:year-:month-:day-:title/" # change the post URL to look like the [params] - # number of recent posts that will be shown in the sidebar - default is 5 - SidebarRecentLimit = 5 + # number of recent posts that will be shown in the sidebar - set to 0 or remove to hide this section + sidebarRecentLimit = 10 # sidebar customization - passed to markdownify sidebar_header = "Sidebar Header" -- cgit v1.2.3