Skip to content

Commit

Permalink
Refactor sidebar logic + Add Table of Contents in reading page (hugo-…
Browse files Browse the repository at this point in the history
…toha#33)

* Refactor sidebar logic + fix responsiveness

* Add TOC

* Add Pagination

* Update exampleSite

* Update README.md
  • Loading branch information
hossainemruz committed Jul 21, 2020
1 parent 647578e commit fa4d474
Show file tree
Hide file tree
Showing 59 changed files with 1,704 additions and 648 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ markup:
goldmark:
renderer:
unsafe: true
tableOfContents:
startLevel: 2
endLevel: 6
ordered: false

# Enable Google Analytics
googleAnalytics: UA-xxxxxxxx
googleAnalytics: UA-XXXXXXXXX-X

# Enable Disqus forum
disqusShortname: does-not-exist
Expand All @@ -83,6 +87,9 @@ params:
# specify whether you want to write blog post or not
enableBlogPost: true

# specify whether you want to show Table of Contents in reading page
enableTOC: true

# specify the list of custom menus that you want to show in the top navbar.
# they will be separated by a divider from the main menus.
customMenus:
Expand All @@ -92,6 +99,7 @@ params:
# some information about you
author:
name: "Jane Doe"
nickname: "Jane"
image: "images/avatar.png"
# give your some contact information. they will be used in the footer
contactInfo:
Expand Down Expand Up @@ -192,7 +200,7 @@ Here, are the current plan and progress of various components of this theme. The

- [x] Post Cards
- [x] Sidebar
- [ ] Pagination
- [x] Pagination

### Reading Page

Expand All @@ -201,7 +209,7 @@ Here, are the current plan and progress of various components of this theme. The
- [x] Next & Previous Page Navigation
- [x] `Improve This Page` Button
- [x] Disqus Comment
- [ ] Option to navigate to list page
- [x] Option to navigate to list page

### Tracking and Comments

Expand Down
9 changes: 8 additions & 1 deletion exampleSite/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ markup:
goldmark:
renderer:
unsafe: true
tableOfContents:
startLevel: 2
endLevel: 6
ordered: false

# Enable Google Analytics
googleAnalytics: UA-xxxxxxxx
googleAnalytics: UA-XXXXXXXXX-X

# Enable Disqus forum
disqusShortname: does-not-exist
Expand All @@ -32,6 +36,9 @@ params:
# specify whether you want to write blog post or not
enableBlogPost: true

# specify whether you want to show Table of Contents in reading page
enableTOC: true

# specify the list of custom menus that you want to show in the top navbar.
# they will be separated by a divider from the main menus.
customMenus:
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/data/sections/achievements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ section:
weight: 6
showOnNavbar: true
# Can optionally hide the title in sections
# hideTitle: true
# hideTitle: true

# Your achievements achievements
achievements:
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/data/sections/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ section:
weight: 4
showOnNavbar: true
# Can optionally hide the title in sections
# hideTitle: true
# hideTitle: true

# filter buttons
buttons:
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/data/sections/recent-posts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ section:
weight: 5
showOnNavbar: true
# Can optionally hide the title in sections
# hideTitle: true
# hideTitle: true

# no additional configuration is required
2 changes: 1 addition & 1 deletion exampleSite/data/sections/skills.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ section:
weight: 2
showOnNavbar: true
# Can optionally hide the title in sections
# hideTitle: true
# hideTitle: true

# Your Skills.
# Give a summary of you each skill in the summary section.
Expand Down
2 changes: 1 addition & 1 deletion layouts/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ end }}

{{ define "navbar" }}
{{ partial "navbar-2.html" (dict "baseURL" .Site.BaseURL "title" .Site.Title "hasToggleButton" false) }}
{{ partial "navigators/navbar-2.html" (dict "baseURL" .Site.BaseURL "title" .Site.Title "hasToggleButton" false) }}
{{ end }}

{{ define "content" }}
Expand Down
8 changes: 7 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
{{ end }}
</head>

<body>
<body data-spy="scroll" data-target="#TableOfContents" data-offset="80">
<div class="container-fluid bg-dimmed wrapper">
<!----- ADD NAVBAR --------------->
{{ block "navbar" . }} {{ end }}

<!----- ADD SIDEBAR --------------->
{{ block "sidebar" . }} {{ end }}

<!----- ADD PAGE CONTENT --------->
{{ block "content" . }} {{ end }}

<!----- ADD TABLE OF CONTENTS ----------->
{{ block "toc" . }} {{ end }}
</div>

<!------- ADD FOOTER ------------>
Expand Down
53 changes: 29 additions & 24 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
{{ define "header" }}
<link rel="stylesheet" href="/assets/css/list.css">
<link rel="stylesheet" href="/assets/css/navigators/sidebar.css">
{{ end }}

{{ define "navbar" }}
{{ partial "navbar-2.html" (dict "baseURL" .Site.BaseURL "title" .Site.Title "hasToggleButton" true "navBrandURL" .Site.BaseURL ) }}
{{ partial "navigators/navbar-2.html" . }}
{{ end }}

{{ define "content" }}
<div class="sidebar" id="sidebar">
<div class="sidebar-tree">
<input type="text" name="filtr-search" value="" placeholder="Search" data-search="" id="search-box" />
<ul class="tree" id="tree">
<li id="list-heading"><a href="#" data-filter="all">{{.Title}}</a></li>
<div class="subtree">
{{ partial "sections.html" .Sections }}
{{ define "sidebar" }}
<section class="sidebar-section" id="sidebar-section">
<div class="sidebar-holder">
<div class="sidebar" id="sidebar">
<input type="text" value="" placeholder="Search" data-search="" id="search-box" />
<div class="sidebar-tree">
<ul class="tree" id="tree">
<li id="list-heading"><a href="/posts" data-filter="all">Posts</a></li>
<div class="subtree">
{{ partial "navigators/sidebar.html" (dict "menus" .Site.Menus.sidebar "ctx" .) }}
</div>
</ul>
</div>
</ul>
</div>
</div>
</div>
</section>
{{ end }}

{{ define "content" }}
<section class="content-section" id="content-section">
<div class="content container-fluid" id="content">
<div class="content-cards">
<div class="container-fluid filtr-container post-cards" id="post-cards">
{{ range (where site.RegularPages "Type" "in" site.Params.mainSections) }}
{{ partial "cards/post.html" . }}
{{ end }}
{{/* {{ $paginator := .Paginate .Site.RegularPages 120 }}
{{ range $paginator.Pages }}
{{ partial "cards/post.html" . }}
{{ end }} */}}
</div>
{{/* <div class="paginator">
{{ template "_internal/pagination.html" . }}
</div> */}}
<div class="container-fluid post-card-holder" id="post-card-holder">
{{ $paginator := .Paginate .RegularPagesRecursive 12 }}
{{ range $paginator.Pages }}
{{ partial "cards/post.html" . }}
{{ end }}
</div>
<div class="paginator">
{{ template "_internal/pagination.html" . }}
</div>
</div>
</section>
{{ end }}

{{ define "scripts" }}
Expand Down
111 changes: 74 additions & 37 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,93 @@
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-dark.min.css"
/>
<link rel="stylesheet" href="/assets/css/single.css" />
<link rel="stylesheet" href="/assets/css/navigators/sidebar.css">
{{ end }}

{{ define "navbar" }}
{{ partial "navbar-2.html" (dict "baseURL" .Site.BaseURL "title" .Site.Title "hasToggleButton" false "navBrandURL" "/posts") }}
{{ partial "navigators/navbar-2.html" . }}
{{ end }}

{{ define "content" }}
<div class="container p-0 read-area">
<!--Hero Area-->
<div class="hero-area col-sm-12" style='background-image: url({{ strings.TrimSuffix "/" .Site.BaseURL }}{{ partial "helpers/get-hero.html" . }});'>
</div>

<!--Content Start-->
<div class="page-content">
<div class="author-profile ml-auto align-self-lg-center">
<img class="rounded-circle" src='{{ partial "helpers/get-author-image.html" . }}'/>
<h5 class="author-name">{{ partial "helpers/get-author-name.html" . }}</h5>
<p>{{ .Page.Date.Format "January 2, 2006" }}</p>
</div>

<div class="title">
<h1>{{ .Page.Title }}</h1>
{{ define "sidebar" }}
<section class="sidebar-section" id="sidebar-section">
<div class="sidebar-holder">
<div class="sidebar" id="sidebar">
<input type="text" value="" placeholder="Search" data-search="" id="search-box" />
<div class="sidebar-tree">
<ul class="tree" id="tree">
<li id="list-heading"><a href="/posts" data-filter="all">Posts</a></li>
<div class="subtree">
{{ partial "navigators/sidebar.html" (dict "menus" .Site.Menus.sidebar "ctx" .) }}
</div>
</ul>
</div>
</div>
</div>
</section>
{{ end }}

<div class="post-content" id="post-content">
{{ .Page.Content }}
{{ define "content" }}
<section class="content-section" id="content-section">
<div class="content">
<div class="container p-0 read-area">
<!--Hero Area-->
<div class="hero-area col-sm-12" id="hero-area" style='background-image: url({{ strings.TrimSuffix "/" .Site.BaseURL }}{{ partial "helpers/get-hero.html" . }});'>
</div>

<!--Content Start-->
<div class="page-content">
<div class="author-profile ml-auto align-self-lg-center">
<img class="rounded-circle" src='{{ partial "helpers/get-author-image.html" . }}'/>
<h5 class="author-name">{{ partial "helpers/get-author-name.html" . }}</h5>
<p>{{ .Page.Date.Format "January 2, 2006" }}</p>
</div>

<div class="title">
<h1>{{ .Page.Title }}</h1>
</div>

<div class="post-content" id="post-content">
{{ .Page.Content }}
</div>

<!--- Improve this page button --->
{{ if .Site.Params.GitRepo }}
<div class="btn-improve-page">
<a href="{{ .Site.Params.GitRepo }}/edit/master/content/{{ .File.Path }}">
<i class="fas fa-code-branch"></i>
Improve This Page
</a>
</div>
{{ end }}

<!---Next and Previous Navigator -->
<hr />
{{ partial "navigators/next-prev-navigator.html" . }}
<hr />
<!-- Add Disqus forum -->
{{ if .Site.DisqusShortname }}
{{ partial "disqus.html" . }}
{{ end }}
</div>
</div>
</div>
</section>
{{ end }}

<!--- Improve this page button --->
{{ if .Site.Params.GitRepo }}
<div class="btn-improve-page">
<a href="{{ .Site.Params.GitRepo }}/edit/master/content/{{ .File.Path }}">
<i class="fas fa-code-branch"></i>
Improve This Page
</a>
{{ define "toc" }}
<section class="toc-section" id="toc-section">
{{ if site.Params.enableTOC }}
<div class="toc-holder">
<h5 class="text-center pl-3">Table of Contents</h5>
<hr>
<div class="toc">
{{ .TableOfContents }}
</div>
</div>
{{ end }}

<!---Next and Previous Navigator -->
<hr />
{{ partial "next-prev-navigator.html" . }}
<hr />
<!-- Add Disqus forum -->
{{ if .Site.DisqusShortname }}
{{ partial "disqus.html" . }}
{{ end }}
</div>
</section>
{{ end }}


{{ define "scripts" }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
<script src="/assets/js/single.js"></script>
Expand Down
21 changes: 11 additions & 10 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
{{- partial "header.html" . -}}

<!-- import index page specific headers -->
<link rel="stylesheet" href="/assets/css/home.css" />
<link rel="stylesheet" href="/assets/css/about.css" />
<link rel="stylesheet" href="/assets/css/skills.css" />
<link rel="stylesheet" href="/assets/css/experiences.css" />
<link rel="stylesheet" href="/assets/css/projects.css" />
<link rel="stylesheet" href="/assets/css/recent-posts.css" />
<link rel="stylesheet" href="/assets/css/achievements.css" />
<link rel="stylesheet" href="/assets/css/sections/home.css" />
<link rel="stylesheet" href="/assets/css/sections/about.css" />
<link rel="stylesheet" href="/assets/css/sections/skills.css" />
<link rel="stylesheet" href="/assets/css/sections/experiences.css" />
<link rel="stylesheet" href="/assets/css/sections/projects.css" />
<link rel="stylesheet" href="/assets/css/sections/recent-posts.css" />
<link rel="stylesheet" href="/assets/css/sections/achievements.css" />

<!-- Add Google Analytics if enabled in configuration -->
{{ if .Site.GoogleAnalytics }}
Expand All @@ -22,10 +22,10 @@
<body data-spy="scroll" data-target="#top-navbar" data-offset="100">

<!--- NAVBAR ------------------------->
{{- partial "navbar.html" . -}}
{{- partial "navigators/navbar.html" . -}}

<!--- ADD HOME SECTION ---------------->
{{- partial "home.html" . -}}
{{- partial "sections/home.html" . -}}

<!--- ADD OPTIONAL SECTIONS ----------->
{{ if .Site.Data.sections }}
Expand All @@ -36,7 +36,7 @@
{{ if .section.template }}
{{- partial .section.template . -}}
{{ else }}
{{- partial (printf "%s.html" (replace (lower .section.name) " " "-")) . -}}
{{- partial (printf "sections/%s.html" (replace (lower .section.name) " " "-")) . -}}
{{ end }}
</div>
<!--- alter background color for next section --->
Expand All @@ -59,5 +59,6 @@
<script src="/assets/js/itype.min.js"></script>
<script src="/assets/js/github-button.js"></script>
<script src="/assets/js/home.js"></script>
<script src="/assets/js/jquery.filterizr.min.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion layouts/partials/cards/post.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="filtr-item" data-category='{{ partial "helpers/get-categories.html" . }}'>
<div class="post-card">
<a href="{{ .RelPermalink }}" class="post-card-link">
<div class="card">
<div class="card-head">
Expand Down
Loading

0 comments on commit fa4d474

Please sign in to comment.