From fa4d47497403491cff184d226a5b2a07ad5dc081 Mon Sep 17 00:00:00 2001 From: "Md. Emruz Hossain" Date: Wed, 22 Jul 2020 04:14:08 +0600 Subject: [PATCH] Refactor sidebar logic + Add Table of Contents in reading page (#33) * Refactor sidebar logic + fix responsiveness * Add TOC * Add Pagination * Update exampleSite * Update README.md --- README.md | 14 +- exampleSite/config.yaml | 9 +- exampleSite/data/sections/achievements.yaml | 2 +- exampleSite/data/sections/projects.yaml | 2 +- exampleSite/data/sections/recent-posts.yaml | 2 +- exampleSite/data/sections/skills.yaml | 2 +- layouts/404.html | 2 +- layouts/_default/baseof.html | 8 +- layouts/_default/list.html | 55 +- layouts/_default/single.html | 117 ++-- layouts/index.html | 21 +- layouts/partials/cards/post.html | 2 +- layouts/partials/cards/project.html | 2 +- layouts/partials/cards/recent-post.html | 2 +- layouts/partials/cards/skill.html | 2 +- .../partials/experiences/experience-info.html | 5 - layouts/partials/header.html | 3 +- layouts/partials/helpers/get-categories.html | 5 - .../{progress => misc}/soft-skills.html | 0 layouts/partials/navbar-2.html | 16 - layouts/partials/navigators/navbar-2.html | 19 + layouts/partials/{ => navigators}/navbar.html | 8 +- .../{ => navigators}/next-prev-navigator.html | 0 layouts/partials/navigators/sidebar.html | 22 + layouts/partials/scripts.html | 2 +- layouts/partials/sections.html | 11 - layouts/partials/{ => sections}/about.html | 8 +- .../partials/{ => sections}/achievements.html | 2 +- .../achievements/entry.html} | 0 .../partials/{ => sections}/experiences.html | 10 +- .../sections/experiences/experience-info.html | 5 + .../experiences/horizontal-line.html | 0 .../experiences/multiple-positions.html | 0 .../experiences/single-position.html | 0 .../experiences/vertical-line.html | 0 layouts/partials/{ => sections}/home.html | 0 layouts/partials/{ => sections}/projects.html | 0 .../partials/{ => sections}/recent-posts.html | 0 layouts/partials/{ => sections}/skills.html | 0 static/assets/css/404.css | 22 +- static/assets/css/list.css | 532 ++++++++---------- static/assets/css/main.css | 47 +- static/assets/css/{ => navigators}/navbar.css | 105 +++- static/assets/css/navigators/sidebar.css | 315 +++++++++++ static/assets/css/projects.css | 61 -- static/assets/css/recent-posts.css | 28 - static/assets/css/{ => sections}/about.css | 25 +- .../css/{ => sections}/achievements.css | 29 +- .../assets/css/{ => sections}/experiences.css | 24 +- static/assets/css/{ => sections}/home.css | 22 +- static/assets/css/sections/projects.css | 113 ++++ static/assets/css/sections/recent-posts.css | 82 +++ static/assets/css/{ => sections}/skills.css | 29 +- static/assets/css/single.css | 331 ++++++++++- static/assets/css/style.css | 48 +- static/assets/js/home.js | 30 +- static/assets/js/list.js | 68 +-- static/assets/js/main.js | 122 ++++ static/assets/js/single.js | 23 + 59 files changed, 1735 insertions(+), 679 deletions(-) delete mode 100644 layouts/partials/experiences/experience-info.html delete mode 100644 layouts/partials/helpers/get-categories.html rename layouts/partials/{progress => misc}/soft-skills.html (100%) delete mode 100644 layouts/partials/navbar-2.html create mode 100644 layouts/partials/navigators/navbar-2.html rename layouts/partials/{ => navigators}/navbar.html (85%) rename layouts/partials/{ => navigators}/next-prev-navigator.html (100%) create mode 100644 layouts/partials/navigators/sidebar.html delete mode 100644 layouts/partials/sections.html rename layouts/partials/{ => sections}/about.html (86%) rename layouts/partials/{ => sections}/achievements.html (88%) rename layouts/partials/{misc/achievement.html => sections/achievements/entry.html} (100%) rename layouts/partials/{ => sections}/experiences.html (63%) create mode 100644 layouts/partials/sections/experiences/experience-info.html rename layouts/partials/{ => sections}/experiences/horizontal-line.html (100%) rename layouts/partials/{ => sections}/experiences/multiple-positions.html (100%) rename layouts/partials/{ => sections}/experiences/single-position.html (100%) rename layouts/partials/{ => sections}/experiences/vertical-line.html (100%) rename layouts/partials/{ => sections}/home.html (100%) rename layouts/partials/{ => sections}/projects.html (100%) rename layouts/partials/{ => sections}/recent-posts.html (100%) rename layouts/partials/{ => sections}/skills.html (100%) rename static/assets/css/{ => navigators}/navbar.css (62%) create mode 100644 static/assets/css/navigators/sidebar.css delete mode 100644 static/assets/css/projects.css delete mode 100644 static/assets/css/recent-posts.css rename static/assets/css/{ => sections}/about.css (94%) rename static/assets/css/{ => sections}/achievements.css (85%) rename static/assets/css/{ => sections}/experiences.css (90%) rename static/assets/css/{ => sections}/home.css (82%) create mode 100644 static/assets/css/sections/projects.css create mode 100644 static/assets/css/sections/recent-posts.css rename static/assets/css/{ => sections}/skills.css (64%) create mode 100644 static/assets/js/main.js diff --git a/README.md b/README.md index 5215263..5ea8696 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: @@ -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: @@ -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 @@ -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 diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 2cd6e1d..8af4441 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -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 @@ -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: diff --git a/exampleSite/data/sections/achievements.yaml b/exampleSite/data/sections/achievements.yaml index eee213b..a4b6838 100644 --- a/exampleSite/data/sections/achievements.yaml +++ b/exampleSite/data/sections/achievements.yaml @@ -5,7 +5,7 @@ section: weight: 6 showOnNavbar: true # Can optionally hide the title in sections - # hideTitle: true + # hideTitle: true # Your achievements achievements achievements: diff --git a/exampleSite/data/sections/projects.yaml b/exampleSite/data/sections/projects.yaml index ea0c02e..618fa4e 100644 --- a/exampleSite/data/sections/projects.yaml +++ b/exampleSite/data/sections/projects.yaml @@ -5,7 +5,7 @@ section: weight: 4 showOnNavbar: true # Can optionally hide the title in sections - # hideTitle: true + # hideTitle: true # filter buttons buttons: diff --git a/exampleSite/data/sections/recent-posts.yaml b/exampleSite/data/sections/recent-posts.yaml index 77b8776..f2a1977 100644 --- a/exampleSite/data/sections/recent-posts.yaml +++ b/exampleSite/data/sections/recent-posts.yaml @@ -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 diff --git a/exampleSite/data/sections/skills.yaml b/exampleSite/data/sections/skills.yaml index 8a8aaac..4113fd8 100644 --- a/exampleSite/data/sections/skills.yaml +++ b/exampleSite/data/sections/skills.yaml @@ -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. diff --git a/layouts/404.html b/layouts/404.html index 45b51d2..5c2c730 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -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" }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 1ed13f1..e47c959 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -14,13 +14,19 @@ {{ end }} - +
{{ block "navbar" . }} {{ end }} + + {{ block "sidebar" . }} {{ end }} + {{ block "content" . }} {{ end }} + + + {{ block "toc" . }} {{ end }}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 5f463ab..b7a05e5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,39 +1,44 @@ {{ define "header" }} + {{ 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 "sidebar" }} + {{ end }} {{ define "content" }} - +
-
-
- {{ 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 }} */}} -
- {{/*
- {{ template "_internal/pagination.html" . }} -
*/}} +
+ {{ $paginator := .Paginate .RegularPagesRecursive 12 }} + {{ range $paginator.Pages }} + {{ partial "cards/post.html" . }} + {{ end }} +
+
+ {{ template "_internal/pagination.html" . }}
+
{{ end }} {{ define "scripts" }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8c2de23..bf1304b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -4,55 +4,92 @@ href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-dark.min.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 "sidebar" }} + {{ end }} {{ define "content" }} -
- -
-
- - -
-
- -
{{ partial "helpers/get-author-name.html" . }}
-

{{ .Page.Date.Format "January 2, 2006" }}

-
- -
-

{{ .Page.Title }}

-
- -
- {{ .Page.Content }} -
- - - {{ if .Site.Params.GitRepo }} -
- - - Improve This Page - +
+
+
+ +
- {{ end }} - - -
- {{ partial "next-prev-navigator.html" . }} -
- - {{ if .Site.DisqusShortname }} - {{ partial "disqus.html" . }} - {{ end }} -
+ + +
+
+ +
{{ partial "helpers/get-author-name.html" . }}
+

{{ .Page.Date.Format "January 2, 2006" }}

+
+ +
+

{{ .Page.Title }}

+
+ +
+ {{ .Page.Content }} +
+ + + {{ if .Site.Params.GitRepo }} + + {{ end }} + + +
+ {{ partial "navigators/next-prev-navigator.html" . }} +
+ + {{ if .Site.DisqusShortname }} + {{ partial "disqus.html" . }} + {{ end }} +
+
+
+ {{ end }} +{{ define "toc" }} +
+ {{ if site.Params.enableTOC }} +
+
Table of Contents
+
+
+ {{ .TableOfContents }} +
+
+ {{ end }} +
+{{ end }} {{ define "scripts" }} diff --git a/layouts/index.html b/layouts/index.html index a7f621c..dc93e8c 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,13 +6,13 @@ {{- partial "header.html" . -}} - - - - - - - + + + + + + + {{ if .Site.GoogleAnalytics }} @@ -22,10 +22,10 @@ - {{- partial "navbar.html" . -}} + {{- partial "navigators/navbar.html" . -}} - {{- partial "home.html" . -}} + {{- partial "sections/home.html" . -}} {{ if .Site.Data.sections }} @@ -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 }}
@@ -59,5 +59,6 @@ + diff --git a/layouts/partials/cards/post.html b/layouts/partials/cards/post.html index 6787e28..663510b 100644 --- a/layouts/partials/cards/post.html +++ b/layouts/partials/cards/post.html @@ -1,4 +1,4 @@ -
+
diff --git a/layouts/partials/cards/project.html b/layouts/partials/cards/project.html index dfd8918..17bf3b0 100644 --- a/layouts/partials/cards/project.html +++ b/layouts/partials/cards/project.html @@ -1,5 +1,5 @@
diff --git a/layouts/partials/cards/recent-post.html b/layouts/partials/cards/recent-post.html index 7295f86..5288b9f 100644 --- a/layouts/partials/cards/recent-post.html +++ b/layouts/partials/cards/recent-post.html @@ -1,4 +1,4 @@ -
+
diff --git a/layouts/partials/cards/skill.html b/layouts/partials/cards/skill.html index d8e1732..0da4050 100644 --- a/layouts/partials/cards/skill.html +++ b/layouts/partials/cards/skill.html @@ -1,4 +1,4 @@ -
+
{{ if .icon }} diff --git a/layouts/partials/experiences/experience-info.html b/layouts/partials/experiences/experience-info.html deleted file mode 100644 index c4e1a92..0000000 --- a/layouts/partials/experiences/experience-info.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ if gt (len .positions) 1 }} - {{ partial "experiences/multiple-positions" . }} -{{ else }} - {{ partial "experiences/single-position.html" . }} -{{ end }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index b898b98..9ffdb2f 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -5,7 +5,8 @@ - + + diff --git a/layouts/partials/helpers/get-categories.html b/layouts/partials/helpers/get-categories.html deleted file mode 100644 index f9d39b6..0000000 --- a/layouts/partials/helpers/get-categories.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ $categories:= ""}} -{{ if .Params.categories }} - {{ $categories = delimit .Params.categories "," }} -{{ end }} -{{ return $categories }} diff --git a/layouts/partials/progress/soft-skills.html b/layouts/partials/misc/soft-skills.html similarity index 100% rename from layouts/partials/progress/soft-skills.html rename to layouts/partials/misc/soft-skills.html diff --git a/layouts/partials/navbar-2.html b/layouts/partials/navbar-2.html deleted file mode 100644 index 03fb869..0000000 --- a/layouts/partials/navbar-2.html +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/layouts/partials/navigators/navbar-2.html b/layouts/partials/navigators/navbar-2.html new file mode 100644 index 0000000..bca52a9 --- /dev/null +++ b/layouts/partials/navigators/navbar-2.html @@ -0,0 +1,19 @@ + diff --git a/layouts/partials/navbar.html b/layouts/partials/navigators/navbar.html similarity index 85% rename from layouts/partials/navbar.html rename to layouts/partials/navigators/navbar.html index fba1b31..0873fa4 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -1,4 +1,4 @@ -