summaryrefslogtreecommitdiff
path: root/layouts/partials
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/footer.html4
-rw-r--r--layouts/partials/head/meta.html21
-rw-r--r--layouts/partials/head/seo.html86
-rw-r--r--layouts/partials/header.html6
-rw-r--r--layouts/partials/list/pagination.html28
-rw-r--r--layouts/partials/list/post-card.html45
-rw-r--r--layouts/partials/list/recent-posts.html50
-rw-r--r--layouts/partials/navmenu.html58
-rw-r--r--layouts/partials/single/next-prev.html30
-rw-r--r--layouts/partials/single/tags.html17
10 files changed, 260 insertions, 85 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index a74a6a4..a934e59 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,3 +1,3 @@
-<footer role="contentinfo">
- <p>&copy; {{ now.Year }} {{ site.Params.author.name }}</p>
+<footer class="site__footer" role="contentinfo">
+ <p>&copy; {{ now.Year }} {{ site.Params.author.name }}</p>
</footer>
diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html
index d0358a1..f739838 100644
--- a/layouts/partials/head/meta.html
+++ b/layouts/partials/head/meta.html
@@ -1,22 +1,27 @@
-<!-- Basic Meta -->
+{{- /* Basic Meta */ -}}
<meta name="author" content="{{ site.Params.author.name | default site.Title }}">
<meta name="robots" content="index, follow">
-<!-- Open Graph (OG) -->
+{{- /* Open Graph */ -}}
<meta property="og:title" content="{{ .Title | default site.Title }}">
<meta property="og:description" content="{{ .Description | default .Summary }}">
<meta property="og:type" content="{{ if .IsHome }}website{{ else }}article{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:site_name" content="{{ site.Title }}">
-{{- with .Params.images }}
- <meta property="og:image" content="{{ (index . 0) | absURL }}">
+{{- with site.Params.logo }}
+ <meta property="og:image" content="{{ . | absURL }}">
+{{- end }}
+{{- if .IsPage }}
+ <meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
+ {{- with .Lastmod }}
+ <meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}">
+ {{- end }}
{{- end }}
-<!-- Twitter Card -->
+{{- /* Twitter Card */ -}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ .Title | default site.Title }}">
<meta name="twitter:description" content="{{ .Description | default .Summary }}">
-{{- with .Params.images }}
- <meta name="twitter:image" content="{{ (index . 0) | absURL }}">
+{{- with site.Params.logo }}
+ <meta name="twitter:image" content="{{ . | absURL }}">
{{- end }}
-
diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html
index 2c617e1..628ea2c 100644
--- a/layouts/partials/head/seo.html
+++ b/layouts/partials/head/seo.html
@@ -1,50 +1,46 @@
-{{ if .IsPage }}
- <script type="application/ld+json">
- {
- "@context": "https://schema.org",
- "@type": "Article",
- "headline": {{ printf "%q" .Title }},
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "{{ if .IsPage }}Article{{ else }}WebSite{{ end }}",
+ "url": {{ .Permalink }},
+ "name": {{ with .Title }}{{ . }}{{ else }}{{ site.Title }}{{ end }},
+ "headline": {{ with .Title }}{{ . }}{{ else }}{{ site.Title }}{{ end }},
+ "description": {{ with .Description }}{{ . }}{{ else }}{{ site.Params.description | default site.Title }}{{ end }},
+ {{- with .Params.images }}
+ "image": [
+ {{- range $i, $image := . }}
+ {{- if $i }},{{ end }}
+ "{{ $image | absURL }}"
+ {{- end }}
+ ],
+ {{- else }}
+ {{- with site.Params.logo }}
+ "image": ["{{ . | absURL }}"],
+ {{- end }}
+ {{- end }}
+ {{- if .IsPage }}
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
- {{ with .Lastmod }}
- "dateModified": "{{ .Format "2006-01-02T15:04:05Z07:00" }}",
- {{ end }}
- "author": {
- "@type": "Person",
- "name": {{ printf "%q" (site.Params.author.name | default site.Title) }}
- },
- "publisher": {
- "@type": "Person",
- "name": {{ printf "%q" site.Title }},
- "logo": {
- "@type": "ImageObject",
- "url": "{{ site.Params.logo | absURL }}"
- }
+ {{- with .Lastmod }}
+ "dateModified": "{{ .Format "2006-01-02T15:04:05Z07:00" }}",
+ {{- end }}
+ {{- end }}
+ "author": {
+ "@type": "Person",
+ "name": "{{ site.Params.author.name | default site.Title }}"
+ },
+ "publisher": {
+ "@type": "Organization",
+ "name": "{{ site.Title }}"
+ {{- with site.Params.logo }},
+ "logo": {
+ "@type": "ImageObject",
+ "url": "{{ . | absURL }}"
+ }
+ {{- end }}
},
"mainEntityOfPage": {
"@type": "WebPage",
- "@id": "{{ .Permalink }}"
- },
- "image": [
- {{ with .Params.images }}"{{ (index . 0) | absURL }}"{{ end }}
- ]
- }
- </script>
-{{ else if .IsHome }}
- <script type="application/ld+json">
- {
- "@context": "https://schema.org",
- "@type": "WebSite",
- "url": "{{ site.BaseURL }}",
- "name": {{ printf "%q" site.Title }},
- "author": {
- "@type": "Person",
- "name": {{ printf "%q" (site.Params.author.name | default site.Title) }}
- },
- "publisher": {
- "@type": "Person",
- "name": {{ printf "%q" site.Title }}
- }
+ "@id": {{ .Permalink }}
}
- </script>
-{{ end }}
-
+}
+</script>
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index a496628..7b728a6 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,6 +1,6 @@
-<header role="banner">
- <a href="{{ site.Home.RelPermalink }}" rel="home" class="site-title">
- {{ site.Title }}
+<header class="site__header" role="banner">
+ <a href="{{ site.Home.RelPermalink }}" rel="home" class="site-{{ if site.Params.logo }}logo{{ else }}title{{ end }}">
+ {{ with site.Params.logo}}{{ . }}{{ else }}{{ site.Title }}{{end}}
</a>
{{ partial "navmenu.html" (dict "menuID" "main" "page" .) }}
diff --git a/layouts/partials/list/pagination.html b/layouts/partials/list/pagination.html
new file mode 100644
index 0000000..47d90ff
--- /dev/null
+++ b/layouts/partials/list/pagination.html
@@ -0,0 +1,28 @@
+{{- $paginator := . }}
+{{- if gt $paginator.TotalPages 1 }}
+<nav class="pagination" aria-label="{{ lang.Translate "pagination.label" | default "Page navigation" }}">
+ {{- if $paginator.HasPrev }}
+ <a href="{{ $paginator.Prev.URL }}"
+ class="pagination__link"
+ rel="prev"
+ aria-label="{{ lang.Translate "pagination.previous_page" | default "Previous page" }}"
+ >
+ ← {{ lang.Translate "common.previous" | default "Previous" }}
+ </a>
+ {{- end }}
+
+ <p class="pagination__current">
+ {{ lang.Translate "pagination.position" $paginator.PageNumber $paginator.TotalPages | default (printf "Page %d of %d" $paginator.PageNumber $paginator.TotalPages) }}
+ </p>
+
+ {{- if $paginator.HasNext }}
+ <a href="{{ $paginator.Next.URL }}"
+ class="pagination__link"
+ rel="next"
+ aria-label="{{ lang.Translate "pagination.next_page" | default "Next page" }}"
+ >
+ {{ lang.Translate "common.next" | default "Next" }} →
+ </a>
+ {{- end }}
+</nav>
+{{- end }}
diff --git a/layouts/partials/list/post-card.html b/layouts/partials/list/post-card.html
new file mode 100644
index 0000000..12eada4
--- /dev/null
+++ b/layouts/partials/list/post-card.html
@@ -0,0 +1,45 @@
+{{- $post := . }}
+<article class="post-card">
+ <header class="post-card__header">
+ <h3 class="post-card__title">
+ <a href="{{ $post.RelPermalink }}" class="post-card__link">
+ {{ $post.Title }}
+ </a>
+ </h3>
+ <div class="post-card__meta">
+ <time datetime="{{ $post.Date.Format "2006-01-02T15:04:05Z07:00" }}" class="post-card__date">
+ {{ $post.Date | time.Format ":date_medium" }}
+ </time>
+ {{- with $post.ReadingTime }}
+ <p class="post-card__reading-time">
+ {{ lang.Translate "list.reading_time" . | default (printf "Estimated reading time: %s min" .) }}
+ </p>
+ {{- end }}
+ </div>
+ </header>
+
+ {{- with $post.Summary }}
+ <div class="post-card__summary">
+ {{ . }}
+ </div>
+ {{- end }}
+
+ {{- with $post.Params.tags }}
+ <footer class="post-card__tags">
+ <ul class="post-card__tags-list">
+ {{- range first 3 . }}
+ <li class="post-card__tags-item">
+ #{{ . }}
+ </li>
+ {{- end }}
+ {{- if gt (len .) 3 }}
+ <li class="post-card__tags-item post-card__tags-more">
+ <span class="post-card__tags-more-count">
+ +{{ sub (len .) 3 }} {{ lang.Translate "common.more" | default "more" }}
+ </span>
+ </li>
+ {{- end }}
+ </ul>
+ </footer>
+ {{- end }}
+</article>
diff --git a/layouts/partials/list/recent-posts.html b/layouts/partials/list/recent-posts.html
new file mode 100644
index 0000000..c1075e2
--- /dev/null
+++ b/layouts/partials/list/recent-posts.html
@@ -0,0 +1,50 @@
+{{- /*
+List of Recent Posts. Accepts a dict with the following optional parameters:
+
+@context {int} count: Number of posts to display (default: 10).
+@context {string} title: Section title (default: "Recent Articles").
+@context {bool} show_view_all: Whether to show "View All Posts" link (default: true).
+
+@example: {{ partial "list/recent-posts.html" (dict "count" 20 "title" "Latest updates" "show_view_all" true) }}
+*/ -}}
+
+{{- $count := .count | default 10 -}}
+{{- $title := .title | default (lang.Translate "posts.recent" | default "Recent Articles") -}}
+{{- $showViewAll := .show_view_all | default true -}}
+
+<section class="recent-posts" aria-labelledby="recent-posts-heading">
+ <header class="recent-posts__header">
+ <h2 id="recent-posts-heading" class="recent-posts__title">
+ {{ $title }}
+ </h2>
+ </header>
+
+ {{- /* Get published 10 most recent posts */ -}}
+ {{- $recentPosts := where site.RegularPages "Date" "!=" nil }}
+ {{- $recentPosts = where $recentPosts ".Date" "le" now }}
+ {{- $recentPosts = first $count $recentPosts }}
+
+ {{- if $recentPosts }}
+ <div class="recent-posts__content">
+ <ul class="recent-posts__list" role="list">
+ {{- range $recentPosts }}
+ <li class="recent-posts__list-item">
+ {{- partial "list/post-card.html" . }}
+ </li>
+ {{- end }}
+ </ul>
+
+ {{- if $showViewAll }}
+ <a href="{{ with site.GetPage "/posts" }}{{ .RelPermalink }}{{ else }}/posts/{{ end }}" class="recent_posts__view-all-link">
+ {{ lang.Translate "posts.view_all" | default "View all posts" }}
+ </a>
+ {{- end }}
+ </div>
+ {{ else }}
+ <div class="recent-posts__empty">
+ <p class="recent_posts__empty-message">
+ {{ lang.Translate "list.empty" | default "No posts in this section." }}
+ </p>
+ </div>
+ {{- end }}
+</section>
diff --git a/layouts/partials/navmenu.html b/layouts/partials/navmenu.html
index 05fd64f..91e53b3 100644
--- a/layouts/partials/navmenu.html
+++ b/layouts/partials/navmenu.html
@@ -1,45 +1,49 @@
{{- /*
+Simplified version of the `hugo new template` menu.html default
Renders a menu for the given menu ID.
-@context {page} page The current page.
-@context {string} menuID The menu ID.
+@context {page} page: The current page.
+@context {string} menuID: The menu ID.
@example: {{ partial "navmenu.html" (dict "menuID" "main" "page" .) }}
*/}}
-{{- $page := .page }}
+{{- $currentPage := .page }}
{{- $menuID := .menuID }}
{{- with index site.Menus $menuID }}
- <nav role="navigation" aria-label="{{ i18n "mainNavigation" | default "Main navigation" }}">
- <ul>
- {{ range . }}
- {{- $attrs := dict "href" .URL }}
- {{- if $page.IsMenuCurrent .Menu . }}
- {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
- {{- else if $page.HasMenuCurrent .Menu .}}
- {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
- {{- end }}
- {{- $name := .Name }}
+<nav role="navigation" aria-label="{{ lang.Translate "header.navmenu" | default "Site navigation" }}" class="header__navigation">
+ <ul class="header__navigation-list">
+ {{- range . }}
+ {{- $isCurrentPage := $currentPage.IsMenuCurrent .Menu . }}
+ {{- $isAncestorPage := $currentPage.HasMenuCurrent .Menu . }}
+ {{- $isActive := or $isCurrentPage $isAncestorPage }}
+ {{- $menuItemName := .Name }}
+
+ {{- $attrs := dict "href" .URL }}
+ {{- if $currentPage.IsMenuCurrent .Menu . }}
+ {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
+ {{- else if $currentPage.HasMenuCurrent .Menu .}}
+ {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
+ {{- end }}
+
<!-- Translations -->
{{- with .Identifier }}
- {{- with T . }}
- {{- $name = . }}
+ {{- with lang.Translate . }}
+ {{- $menuItemName = . }}
{{- end }}
{{- end }}
- <li>
+
+ <li class="header__navigation--list-item">
<a
- {{- range $k, $v := $attrs }}
- {{- with $v }}
- {{- printf " %s=%q" $k $v | safeHTMLAttr }}
- {{- end }}
- {{- end -}}
+ href="{{ .URL }}"
+ class="header__navigation-link{{ if $isActive }} header__navigation-link--active{{ end }}"
+ aria-current="{{ if $isCurrentPage }}page{{ else if $isAncestorPage }}true{{ end }}"
>
- {{ $name }}
+ {{ $menuItemName }}
</a>
</li>
- {{- end }}
- </ul>
- </nav>
-{{- end }}
-
+ {{- end }}
+ </ul>
+</nav>
+{{- end -}}
diff --git a/layouts/partials/single/next-prev.html b/layouts/partials/single/next-prev.html
new file mode 100644
index 0000000..c938990
--- /dev/null
+++ b/layouts/partials/single/next-prev.html
@@ -0,0 +1,30 @@
+{{- /* Navigation for Next and Previous Post */ -}}
+<nav class="post__navigation" aria-label="{{ lang.Translate "post.navigation" | default "Post navigation" }}">
+ <ul class="post__navigation-list">
+ {{- with .PrevInSection }}
+ <li class="post__navigation-prev">
+ <a href="{{ .RelPermalink }}" class="post__navigation-link" rel="prev">
+ <span class="post__navigation-label">
+ {{ lang.Translate "post.previous" | default "Previous post:" }}
+ </span>
+ <span class="post__navigation-title">
+ {{ .Title }}
+ </span>
+ </a>
+ </li>
+ {{- end }}
+
+ {{- with .NextInSection }}
+ <li class="post__navigation-next">
+ <a href="{{ .RelPermalink }}" class="post__navigation-link" rel="next">
+ <span class="post__navigation-label">
+ {{ lang.Translate "post.next" | default "Next post:" }}
+ </span>
+ <span class="post__navigation-title">
+ {{ .Title }}
+ </span>
+ </a>
+ </li>
+ {{- end }}
+ </ul>
+</nav>
diff --git a/layouts/partials/single/tags.html b/layouts/partials/single/tags.html
new file mode 100644
index 0000000..e90b909
--- /dev/null
+++ b/layouts/partials/single/tags.html
@@ -0,0 +1,17 @@
+{{- with .GetTerms "tags" }}
+<section class="post__tags" aria-labelledby="tags-heading">
+ <h2 id="tags-heading" class="post__tags-heading">
+ {{ lang.Translate "tags.name" | default "Tags" }}
+ </h2>
+
+ <ul class="post__tags-list">
+ {{- range . }}
+ <li class="post__tags-item">
+ <a href="{{ .RelPermalink }}" class="post__tags-link" rel="tag">
+ {{ .Title }}
+ </a>
+ </li>
+ {{- end }}
+ </ul>
+</section>
+{{- end }}