various fixes, added pagination and articles prev/next links.
authordanix <danix@danix.xyz>
Mon, 13 Feb 2023 18:53:37 +0000 (19:53 +0100)
committerdanix <danix@danix.xyz>
Mon, 13 Feb 2023 18:53:37 +0000 (19:53 +0100)
13 files changed:
assets/sass/components/_breadcrumbs.scss [new file with mode: 0644]
assets/sass/components/_pagination.scss
assets/sass/libs/_my-mixins.scss
assets/sass/main.scss
layouts/articles/list.html
layouts/page/list-baseof.html
layouts/page/single-baseof.html
layouts/partials/breadcrumbs.html
layouts/partials/head-addition.html
layouts/partials/pagination.html [new file with mode: 0644]
layouts/partials/prev-next.html [new file with mode: 0644]
layouts/post/single-baseof.html
layouts/post/single.html

diff --git a/assets/sass/components/_breadcrumbs.scss b/assets/sass/components/_breadcrumbs.scss
new file mode 100644 (file)
index 0000000..a71e9d6
--- /dev/null
@@ -0,0 +1,41 @@
+/// Inspired by:
+/// Forty by HTML5 UP
+/// html5up.net | @ajlkn
+/// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
+///
+
+/* Breadcrumbs */
+       div#breadcrumbs {
+               font-size: 1rem;
+               ol.crumbs {
+                       cursor: default;
+                       list-style: none;
+                       padding-left: 0;
+
+                       li {
+                               display: inline-block;
+                               padding-left: 0;
+                               vertical-align: middle;
+
+                               &:first-child {
+                                       padding-right: 0.75em;
+                               }
+
+                               &:last-child {
+                                       padding-left: 0.75em;
+                               }
+                       }
+
+                       @include breakpoint('<=xsmall') {
+                               li {
+                                       &:nth-child(n+2):nth-last-child(n+2) {
+                                               display: none;
+                                       }
+
+                                       &:first-child {
+                                               padding-right: 0;
+                                       }
+                               }
+                       }
+               }
+       }
index 0059795..cb39c39 100644 (file)
                                }
                        }
                }
-       }
\ No newline at end of file
+       }
+
+
+       ul.prev-next {
+               cursor: default;
+               list-style: none;
+               padding-left: 0;
+
+               li {
+                       display: inline-block;
+                       padding-left: 0;
+                       vertical-align: middle;
+
+                       &:first-child {
+                               padding-right: 0.75em;
+                       }
+
+                       &:last-child {
+                               padding-left: 0.75em;
+                       }
+               }
+
+               @include breakpoint('<=xsmall') {
+                       li {
+                               &:nth-child(n+2):nth-last-child(n+2) {
+                                       display: none;
+                               }
+
+                               &:first-child {
+                                       padding-right: 0;
+                               }
+                       }
+               }
+       }
index 5e078e4..a901a45 100644 (file)
@@ -1,3 +1,31 @@
+/// Transforms shorthand that can range from 1-to-4 values to be 4 values.
+///
+/// @argument {list} $shorthand
+///
+/// @example scss
+///   .element {
+///     margin: _unpack-shorthand(1em 2em);
+///   }
+///
+///   // CSS Output
+///   .element {
+///     margin: 1em 2em 1em 2em;
+///   }
+///
+/// @access private
+
+@function _unpack-shorthand($shorthand) {
+  @if length($shorthand) == 1 {
+    @return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1);
+  } @else if length($shorthand) == 2 {
+    @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2);
+  } @else if length($shorthand) == 3 {
+    @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2);
+  } @else {
+    @return $shorthand;
+  }
+}
+
 /// hide-visually mixin from Bourbon < https://bourbon.io >
 /// 
 /// Hides an element visually while still allowing the content to be accessible
     width: auto;
   }
 }
+
+/// Provides a concise, one-line method for setting an element’s positioning
+/// properties: `position`, `top`, `right`, `bottom` and `left`. Use a `null`
+/// value to “skip” an edge of the box.
+///
+/// @argument {string} $position
+///   A CSS position value.
+///
+/// @argument {list} $box-edge-values
+///   List of lengths; accepts CSS shorthand.
+///
+/// @example scss
+///   .element {
+///     @include position(relative, 0 null null 10em);
+///   }
+///
+///   // CSS Output
+///   .element {
+///     left: 10em;
+///     position: relative;
+///     top: 0;
+///   }
+///
+/// @example scss
+///   .element {
+///     @include position(absolute, 0);
+///   }
+///
+///   // CSS Output
+///   .element {
+///     position: absolute;
+///     top: 0;
+///     right: 0;
+///     bottom: 0;
+///     left: 0;
+///   }
+///
+/// @require {function} _is-length
+///
+/// @require {function} _unpack-shorthand
+
+@mixin position(
+  $position,
+  $box-edge-values
+) {
+  $box-edge-values: _unpack-shorthand($box-edge-values);
+  $offsets: (
+    "top": nth($box-edge-values, 1),
+    "right": nth($box-edge-values, 2),
+    "bottom": nth($box-edge-values, 3),
+    "left": nth($box-edge-values, 4),
+  );
+
+  position: $position;
+
+  @each $offset, $value in $offsets {
+    @if _is-length($value) {
+      #{$offset}: $value;
+    }
+  }
+}
index 8abbbb6..4f838e9 100644 (file)
@@ -1,5 +1,3 @@
-// BOURBON 
-@import "bourbon/bourbon";
 // HTML5UP
 @import 'libs/vars';
 @import 'libs/functions';
@@ -57,6 +55,7 @@
        @import 'components/actions';
        @import 'components/icons';
        @import 'components/pagination';
+       @import 'components/breadcrumbs';
        @import 'components/table';
        @import 'components/button';
        @import 'components/tiles';
index a14fe3d..83ac646 100644 (file)
@@ -5,13 +5,18 @@
                        {{ .Content }}
                </div>
        </article>
+       <article>
+               <div class="inner">
+                       {{ partial "pagination.html" . }}
+               </div>
+       </article>
 </section>
 <section id="two" class="spotlights">
        <!-- Ranges through content/posts/*.md -->
-       {{ range .Pages }}
+       {{ range .Paginator.Pages }}
        <section>
                <a class="image" href="{{.Permalink}}">
-                       <img src="{{ "bg/bg2.jpg" | absURL}}" alt="suca">
+                       <img src="{{ .Params.featured_image | absURL}}" alt=".Title">
                </a>
                <div class="content">
                        <div class="inner">
@@ -28,7 +33,7 @@
                                        {{ end }}
                                        </h3>
                                </header>
-                               <p>here goes an abstract</p>
+                               <p>{{ .Params.excerpt }}</p>
                                <ul class="actions">
                                        <li><a href="{{.Permalink}}" class="button">Read More</a></li>
                                </ul>
@@ -37,4 +42,9 @@
        </section>
        {{ end }}
 </section>
+<section id="three">
+       <div class="inner">
+               {{ partial "pagination.html" . }}
+       </div>
+</section>
 {{ end }}
index cc5d0eb..a802655 100644 (file)
@@ -12,9 +12,6 @@
                                        </header>
                                        <div class="content">
                                                <p>{{ .Site.Params.Description }}</p>
-                                               <ul class="actions">
-                                                       <li><a href="#one" class="button next scrolly">Let's go!!</a></li>
-                                               </ul>
                                        </div>
                                </div>
                        </section>
index 8fbe887..bf1171a 100644 (file)
@@ -5,6 +5,16 @@
                <a id="top" class="skip-link screen-reader-text" href="#primary">skip to content</a>
                <div id="wrapper">
                        {{- partial "header.html" . -}}
+                       <section id="banner" class="major">
+                               <div class="inner">
+                                       <header class="major">
+                                               <h1>{{ .Site.Title }}</h1>
+                                       </header>
+                                       <div class="content">
+                                               <p>{{ .Site.Params.Description }}</p>
+                                       </div>
+                               </div>
+                       </section>
                        <div id="main">
                                {{- block "page-main" . }}{{- end }}
                        </div>
index 995f7c0..b7faeb3 100644 (file)
@@ -1,9 +1,8 @@
 <div id="breadcrumbs">
-    <p>You're in: </p>
     <ol class="crumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
         {{- /* declare a 'variable' to store the each link position */}}
         {{- $data := newScratch }}
-
+        <li>You're in: </li>
         {{- range $index, $value := .Ancestors.Reverse }}
             <li class="crumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                 {{- /* read the index from loop and add 'one', because it starts counting from zero */}}
@@ -18,6 +17,7 @@
                 </a>
                 {{- /* pass the counter value into schema attribute */}}
                 <meta itemprop="position" content='{{ $data.Get "counter"}}' />
+                <span class="divider"> / </span>
             </li>         
         {{- end }}
             <li class="crumb-item active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
index d975c51..d2a43ec 100644 (file)
@@ -4,8 +4,7 @@
 {{ if .IsPage }}
        {{ if isset .Params "featured_image" }}
        <style media="screen">
-               header#masthead {
-                       height: 60vh;
+               #banner {
                        background-image: url( {{ $.Params.featured_image | absURL }} );
                        background-repeat: no-repeat;
                        background-position: center center;
diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html
new file mode 100644 (file)
index 0000000..ab9f50a
--- /dev/null
@@ -0,0 +1,121 @@
+<!--
+//
+//  PAGE NUMBERS
+//––––––––––––––––––––––––––––––––––––––––––––––––––
+// https://glennmccomb.com/articles/how-to-build-custom-hugo-pagination/
+-->
+{{ $paginator := .Paginator }}
+
+<!-- Number of links either side of the current page. -->
+{{ $adjacent_links := 2 }}
+
+<!-- $max_links = ($adjacent_links * 2) + 1 -->
+{{ $max_links := (add (mul $adjacent_links 2) 1) }}
+
+<!-- $lower_limit = $adjacent_links + 1 -->
+{{ $lower_limit := (add $adjacent_links 1) }}
+
+<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
+{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}
+
+<!-- If there's more than one page. -->
+{{ if gt $paginator.TotalPages 1 }}
+
+  <ul class="pagination align-center">
+    
+    <!-- First page. -->
+    {{ if ne $paginator.PageNumber 1 }}
+    <li>
+      <a class="page" href="{{ $paginator.First.URL }}">
+        <span class="button small">FIRST</span>
+      </a>
+    </li>
+    {{ end }}
+
+    <!-- Previous page. -->
+    {{ if $paginator.HasPrev }}
+    <li>
+      <a class="page" href="{{ $paginator.Prev.URL }}">
+        <span class="button small">PREV</span>
+      </a>
+    </li>
+    {{ end }}
+  
+    <!-- Page numbers. -->
+    {{ range $paginator.Pagers }}
+    
+      {{ $.Scratch.Set "page_number_flag" false }}
+
+      
+      <!-- Advanced page numbers. -->
+      {{ if gt $paginator.TotalPages $max_links }}
+
+
+        <!-- Lower limit pages. -->
+        <!-- If the user is on a page which is in the lower limit.  -->
+        {{ if le $paginator.PageNumber $lower_limit }}
+
+          <!-- If the current loop page is less than max_links. -->
+          {{ if le .PageNumber $max_links }}
+            {{ $.Scratch.Set "page_number_flag" true }}
+          {{ end }}
+
+
+        <!-- Upper limit pages. -->
+        <!-- If the user is on a page which is in the upper limit. -->
+        {{ else if ge $paginator.PageNumber $upper_limit }}
+
+          <!-- If the current loop page is greater than total pages minus $max_links -->
+          {{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
+            {{ $.Scratch.Set "page_number_flag" true }}
+          {{ end }}
+
+
+        <!-- Middle pages. -->
+        {{ else }}
+          
+          {{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
+            {{ $.Scratch.Set "page_number_flag" true }}
+          {{ end }}
+
+        {{ end }}
+
+      
+      <!-- Simple page numbers. -->
+      {{ else }}
+
+        {{ $.Scratch.Set "page_number_flag" true }}
+
+      {{ end }}
+
+      <!-- Output page numbers. -->
+      {{ if eq ($.Scratch.Get "page_number_flag") true }}
+        <li>
+          <a href="{{ .URL }}"  class="page {{ if eq . $paginator }} active{{ end }}">
+            {{ .PageNumber }}
+          </a>
+        </li>
+      {{ end }}
+
+    {{ end }}
+
+    <!-- Next page. -->
+    {{ if $paginator.HasNext }}
+    <li>
+      <a href="{{ $paginator.Next.URL }}" class="page">
+        <span class="button small">NEXT</span>
+      </a>
+    </li>
+    {{ end }}
+
+    <!-- Last page. -->
+    {{ if ne $paginator.PageNumber $paginator.TotalPages }}
+    <li>
+      <a class="page" href="{{ $paginator.Last.URL }}">
+        <span class="button small">LAST</span>
+      </a>
+    </li>
+    {{ end }}
+
+  </ul><!-- .pagination -->
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/prev-next.html b/layouts/partials/prev-next.html
new file mode 100644 (file)
index 0000000..d22f721
--- /dev/null
@@ -0,0 +1,8 @@
+       <ul class="prev-next align-center">
+               {{with .NextInSection }}
+                       <li><a class="button small" href="{{.RelPermalink}}">Next Article</a></li>
+               {{end}}
+               {{with .PrevInSection }}
+                       <li><a class="button small" href="{{.RelPermalink}}">Previous Article</a></li>
+               {{end}}
+       </ul>
index dc44481..d75dd0f 100644 (file)
@@ -1,19 +1,38 @@
 <!DOCTYPE html>
 <html lang="{{ $.Site.LanguageCode | default "en" }}">
        {{- partial "head.html" . -}}
-       <body class="page home">
-               <div id="page">
-                       <a id="top" class="skip-link screen-reader-text" href="#primary">skip to content</a>
+       <body class="article is-preload">
+               <a id="top" class="skip-link screen-reader-text" href="#primary">skip to content</a>
+               <div id="wrapper">
                        {{- partial "header.html" . -}}
-                       {{- partial "breadcrumbs.html" . -}}
-                       <div id="content" class="site-content">
-                               <div id="primary" class="content-area">
-                                       <main id="main" class="site-main">
-                                               {{- block "page-main" . }}{{- end }}
-                                       </main>
+
+                       <section id="banner" class="major">
+                               <div class="inner">
+                                       <header class="major">
+                                               <h1>{{ .Title }}</h1>
+                                       </header>
+                                       <div class="content">
+                                               <p>{{ .Params.excerpt }}</p>
+                                       </div>
                                </div>
+                       </section>
+
+                       <div id="main">
+                               <section id="one">
+                                       <div class="inner">
+                                               {{- partial "breadcrumbs.html" . -}}
+                                               {{- partial "prev-next.html" . -}}
+                                       </div>
+                               </section>
+                               <section id="two">
+                                       {{- block "article-main" . }}{{- end }}
+                               </section>
+                               <section id="three">
+                                       <div class="inner">articoli correlati</div>
+                               </section>
                        </div>
                        {{- partial "footer.html" . -}}
                </div>
+               {{- partial "footer-addition.html" . -}}
        </body>
 </html>
index e475272..aec452e 100644 (file)
@@ -1,7 +1,8 @@
-{{ define "page-main" }}
-<article class="single-page">
-       <div id="page-content">
-               {{ .Content }}
+{{ define "article-main" }}
+<article>
+       <div class="inner">
+               <p>{{ .Content }}</p>
+               <p>firma e metadata</p>
        </div>
 </article>
 {{ end }}