fixed page listing for articles. Now single pages show up even if they're branches...
authordanix <danix@danix.xyz>
Mon, 6 Feb 2023 09:35:47 +0000 (10:35 +0100)
committerdanix <danix@danix.xyz>
Mon, 6 Feb 2023 09:35:47 +0000 (10:35 +0100)
layouts/articles/list-baseof.html [moved from layouts/articles/baseof.html with 92% similarity]
layouts/articles/list.html
layouts/home-baseof.html [moved from layouts/index-baseof.html with 100% similarity]
layouts/home.html [moved from layouts/index.html with 100% similarity]
layouts/partials/breadcrumbs.html [new file with mode: 0644]
layouts/post/single-baseof.html

similarity index 92%
rename from layouts/articles/baseof.html
rename to layouts/articles/list-baseof.html
index 8992f73..9a5985d 100644 (file)
@@ -5,6 +5,7 @@
                <div id="page">
                        <a id="top" class="skip-link screen-reader-text" href="#primary">skip to content</a>
                        {{- partial "header.html" . -}}
+                       {{- partial "breadcrumbs.html" . -}}
                        <div id="content" class="site-content">
                                <div id="primary" class="content-area">
                                        <main id="main" class="site-main">
index 4a4b1f3..d75b6db 100644 (file)
@@ -1,9 +1,6 @@
 {{ define "main" }}
-<article class="entry post">
-       <header>
-               <h2>{{ .Title }}</h2>
-       </header>
-       <div id="content">
+<article class="single-page">
+       <div id="page-content">
                {{ .Content }}
        </div>
 </article>
@@ -11,7 +8,10 @@
        <!-- Ranges through content/posts/*.md -->
        {{ range .Pages }}
        <li>
-               <a href="{{.Permalink}}">{{.Date.Format "01-02-2006"}} | {{.Title}}</a>
+               <div>
+                       <h3 class="article-title"><a href="{{.Permalink}}">{{.Title}}</a></h3>
+                       <p class="byline">by {{ .Params.Author }} on {{.Date.Format "01-02-2006"}}</p>
+               </div>
        </li>
        {{ end }}
 </ul>
similarity index 100%
rename from layouts/index.html
rename to layouts/home.html
diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html
new file mode 100644 (file)
index 0000000..fd8cc6b
--- /dev/null
@@ -0,0 +1,28 @@
+<ol class="crumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
+    {{- /* declare a 'variable' to store the each link position */}}
+    {{- $data := newScratch }}
+
+    {{- 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 */}}
+            {{- $data.Set "counter" $index }}
+            {{- $data.Add "counter" 1 }}
+            <a itemprop="item" href="{{.Permalink}}">
+                {{ if .IsHome }}
+                <span itemprop="name">home</span>
+                {{ else }}
+                <span itemprop="name">{{.Title}}</span>
+                {{ end }}
+            </a>
+            {{- /* pass the counter value into schema attribute */}}
+            <meta itemprop="position" content='{{ $data.Get "counter"}}' />
+        </li>         
+    {{- end }}
+        <li class="crumb-item active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
+            {{- /* add 'one' one more time for the last link position */}}
+            {{- $data.Add "counter" 1 }}
+            <span itemprop="name">{{.Title}}</span>
+            {{- /* pass the counter value into schema attribute */}}
+            <meta itemprop="position" content='{{ $data.Get "counter"}}' />
+        </li>
+</ol>
\ No newline at end of file
index dbe68c7..1253cd5 100644 (file)
@@ -5,6 +5,7 @@
                <div id="page" class="blog-post">
                        <a id="top" class="skip-link screen-reader-text" href="#primary">skip to content</a>
                        {{- partial "header.html" . -}}
+                       {{- partial "breadcrumbs.html" . -}}
                        <div id="content" class="site-content">
                                <div id="primary" class="content-area">
                                        <main id="main" class="site-main">