From 67c49c7432429e77bbd466a90268a92c5448a064 Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Sun, 2 May 2021 05:02:27 +0600 Subject: [PATCH] Fix note layout (#274) * Re-structure note lists Signed-off-by: hossainemruz * Support note splitting Signed-off-by: hossainemruz * Update single page Signed-off-by: hossainemruz * Refactor separator logic in navbar Signed-off-by: hossainemruz --- layouts/notes/list.html | 11 ++++++- layouts/notes/single.html | 6 ++-- .../helpers/add-navbar-separator.html | 25 ++++++++++++++ layouts/partials/navigators/navbar.html | 25 +++++++++----- layouts/partials/note-aggregator.html | 18 ---------- layouts/shortcodes/note.html | 15 ++++----- static/css/layouts/notes.css | 33 +++++++++++++++---- static/js/imagesloaded.pkgd.min.js | 7 ++++ static/js/note.js | 32 ++++++++++++++++++ 9 files changed, 127 insertions(+), 45 deletions(-) create mode 100644 layouts/partials/helpers/add-navbar-separator.html delete mode 100644 layouts/partials/note-aggregator.html create mode 100644 static/js/imagesloaded.pkgd.min.js create mode 100644 static/js/note.js diff --git a/layouts/notes/list.html b/layouts/notes/list.html index f381b6c..f8181c7 100644 --- a/layouts/notes/list.html +++ b/layouts/notes/list.html @@ -40,7 +40,14 @@
- {{ partial "note-aggregator.html" . }} + {{ $paginator := .Paginate .RegularPagesRecursive 10 }} + {{ range $paginator.Pages }} + {{ if .Layout }} + {{/* ignore search.md file*/}} + {{ else }} + {{ .Content }} + {{ end }} + {{ end }}
{{ template "_internal/pagination.html" . }} @@ -51,6 +58,8 @@ {{ define "scripts" }} + + diff --git a/layouts/notes/single.html b/layouts/notes/single.html index b35edb6..152cb52 100644 --- a/layouts/notes/single.html +++ b/layouts/notes/single.html @@ -40,9 +40,7 @@
-
- {{ .Content }} -
+ {{ .Content }}
@@ -50,6 +48,8 @@ {{ define "scripts" }} + + diff --git a/layouts/partials/helpers/add-navbar-separator.html b/layouts/partials/helpers/add-navbar-separator.html new file mode 100644 index 0000000..6fb280e --- /dev/null +++ b/layouts/partials/helpers/add-navbar-separator.html @@ -0,0 +1,25 @@ +{{ $addNavbarSeparator:= false }} + +{{/* If "blog" feature is enabled, then add navbar separator */}} +{{ if site.Params.features.blog.enable }} + {{ $addNavbarSeparator = true }} +{{ end }} + +{{/* If "notes" feature is enabled, then add navbar separator */}} +{{ if site.Params.features.notes.enable }} + {{ $addNavbarSeparator = true }} +{{ end }} + +{{/* If site has custom menus, then add navbar separator */}} +{{ $customMenus := site.Params.customMenus }} +{{ if (index site.Data site.Language.Lang).site.customMenus }} + {{ $customMenus = (index site.Data site.Language.Lang).site.customMenus }} +{{ end }} + +{{ if $customMenus }} + {{ if gt (len $customMenus) 0 }} + {{ $addNavbarSeparator = true }} + {{ end }} +{{ end }} + +{{ return $addNavbarSeparator }} diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index 2daae09..df29cdc 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -1,3 +1,12 @@ +{{/* variables for enabling/disabling various features */}} +{{ $blogEnabled := site.Params.features.blog.enable | default false }} +{{ $notesEnabled := site.Params.features.notes.enable | default false }} + +{{/* keep backward compatibility for blog post */}} +{{ if site.Params.enableBlogPost }} + {{ $blogEnabled = true }} +{{ end }} + {{/* default logos */}} {{ $mainLogo := "/images/main-logo.png" }} {{ $invertedLogo := "/images/inverted-logo.png" }} @@ -84,20 +93,20 @@ {{ end }} {{- end }} - {{ $hasCustomMenus:= false }} - {{ if $customMenus }} - {{ if gt (len $customMenus) 0 }} - {{ $hasCustomMenus = true }} - {{ end }} - {{ end }} - {{ if (or site.Params.enableBlogPost $hasCustomMenus) }} + {{ $shouldAddSeparator:= partial "helpers/add-navbar-separator.html" . }} + {{ if $shouldAddSeparator }} {{ end }} - {{ if site.Params.enableBlogPost }} + {{ if $blogEnabled }} {{ end }} + {{ if $notesEnabled }} + + {{ end }} {{ range $customMenus }}