2 Commits

Author SHA1 Message Date
7c79f83138 Fix pagination for Hugo 0.146 2025-04-20 04:33:37 -05:00
fa89bc6746 Add TODO warning to fix pagination 2025-04-19 01:35:08 -05:00
68 changed files with 222 additions and 133 deletions

View File

@ -198,14 +198,14 @@ video {
max-width: 100%;
}
.post-media > figure img,
.post-media > figure video {
.post-media > figure.border img,
.post-media > figure.border video {
padding: 5px;
border: 7px solid var(--figure-border);
}
figure img,
figure video {
figure.border img,
figure.border video {
padding: 5px;
border: 2px solid var(--figure-border);
}
@ -291,17 +291,17 @@ table.simple tbody tr:nth-child(even) {
/* Icons */
.icon {
width: 1em;
height: 1em;
width: 20px;
height: 20px;
color: var(--text-1);
text-align: center;
display: inline;
vertical-align: sub;
vertical-align: middle;
}
/* workarounds for some icons from jam-icons being non-square aspect ratio */
.icon-code {
width: 1.25em;
h1 svg.icon {
width: 30px;
height: 30px;
}
/* }}} */
@ -315,6 +315,11 @@ table.simple tbody tr:nth-child(even) {
font-weight: bold;
}
.heading-link svg {
width: 15px;
height: 15px;
}
/* }}} */
/* Top bar formatting {{{ */
@ -671,7 +676,6 @@ table.simple tbody tr:nth-child(even) {
display: flex;
gap: 8px;
justify-content: center;
font-size: 32px;
}
.share-buttons a {
@ -686,7 +690,8 @@ table.simple tbody tr:nth-child(even) {
}
.share-buttons svg {
display: block;
width: 32px;
height: 32px;
}
/* https://stackoverflow.com/a/72073682/19003757 */

3
assets/js/share-event.js Normal file
View File

@ -0,0 +1,3 @@
function share_event(service) {
// this function does nothing by default
}

68
exampleSite/hugo.yaml Normal file
View File

@ -0,0 +1,68 @@
baseURL: https://example.com
theme: bobatheme
defaultContentLanguage: en
copyright: '&copy; 2021 bbaovanc <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>'
sectionPagesMenu: main
enableRobotsTXT: true
enableGitInfo: true
pagination:
pagerSize: 5
taxonomies:
_merge: deep
markup: # this just keeps the bobatheme markup styling
_merge: deep
outputs:
_merge: deep
outputFormats:
_merge: deep
params:
author:
name: bbaovanc
# these are for the OpenGraph/Twitter embeds in Hugo
description: Example website for bobatheme
# these are for favicons in bobatheme (disabled by default)
# faviconSVG: favicon.svg
# appleTouchPNG: apple-touch-icon.png
# show reading time (enabled by default)
# readingtime: true
# used for "View source" (unset by default)
# gitFileURL: https://github.com/BBaoVanC/bobatheme/blob/master
# gitFileIcon: github-circle
# gitHistoryURL: https://github.com/BBaoVanC/bobatheme/commits/master
# social media share icons
# shareButtons:
# twitter: true
# facebook: true
# linkedin: true
# reddit: true
# telegram: true
# print: true
# show "Latest Posts" section at bottom of content pages
# latestPostsOnContent: true
# footer: >-
# Some example text for the footer.
# see https://gohugo.io/about/hugo-and-gdpr/#all-privacy-settings
# you probably want to keep this default
privacy:
_merge: deep
languages:
en:
languageName: English
title: Example Website
weight: 1

View File

@ -4,8 +4,6 @@ markup:
lineNos: true
goldmark:
parser:
# don't put <p> around ![]() image in markdown (used to embed any resource now)
wrapStandAloneImageWithinParagraph: false
attribute:
block: true
# this is enabled by default already

View File

@ -7,8 +7,6 @@ table_of_contents:
browser_no_video_support:
other: "Your browser does not support video."
browser_no_video_support_link:
other: "Click here to download it instead."
latest_posts:
other: "Latest Posts"

View File

@ -13,7 +13,7 @@
{{ partial "breadcrumb.html" . }}
{{ end }}
<main id="main-content" {{ if .IsPage }}data-pagefind-body{{ end }}>
<main id="main-content">
{{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
{{ end }}

View File

@ -22,7 +22,11 @@
</div>
{{ end }}
{{ partial "feature-figure.html" . }}
{{ with .Resources.GetMatch "feature" }}
<div class="post-media">
{{ partial "figure.html" (dict "src" .) }}
</div>
{{ end }}
<article class="post-content">
{{ .Content }}

View File

@ -6,7 +6,11 @@
{{ partial "page-metadata/post-short.html" . }}
{{ partial "feature-figure.html" . }}
{{ with .Resources.GetMatch "feature" }}
<div class="post-media">
{{ partial "figure.html" (dict "src" .) }}
</div>
{{ end }}
<div class="page-description">
{{ partial "description-or-summary.html" . }}

View File

@ -1,12 +0,0 @@
{{/* TODO: should we use .PageInner */}}
{{ partial "embed-resource.html" (.Page.Resources.Get .Destination) }}
{{ with .Title }}
{{ errorf "%q" . }}
{{ end }}
{{ with .Attributes }}
{{/* FIXME: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html */}}
{{ errorf "%q" . }}
{{ end }}
{{ with .Text }}
{{ errorf "%q" . }}
{{ end }}

View File

@ -1,21 +0,0 @@
{{ if eq .ResourceType "image" }}
{{/* TODO: figure out whether loading="lazy" should be set because MDN
* claims that images won't work with JS disabled since it would
* make tracking possible, but my experience says otherwise
*/}}
<img src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
{{ else if eq .ResourceType "video" }}
<video controls preload="metadata">
{{/* FIXME
<source src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
*/}}
{{ i18n "browser_no_video_support" }}
<a href="{{ .Permalink }}" target="_blank" rel="noopener">
{{ i18n "browser_no_video_support_link" }}
</video>
{{ else }}
{{/* TODO: could consider implementing more types, listed at:
* https://www.iana.org/assignments/media-types/media-types.xhtml
*/}}
{{ errorf "Handling %q resource not supported" .ResourceType }}
{{ end }}

View File

@ -1,10 +0,0 @@
{{ with .Resources.Get "feature" }}
<div class="post-media">
<figure>
{{ partial "embed-resource.html" . }}
{{ with .Title }}
<figcaption>{{ . }}</figcaption>
{{ end }}
</figure>
</div>
{{ end }}

View File

@ -1 +0,0 @@
<!-- Placeholder for website to add custom post metadata to summaries -->

View File

@ -1,17 +0,0 @@
<figure>
{{ with .Get "src" }}
{{ with $.Page.Resources.Get . }}
{{ partial "embed-resource.html" . }}
{{ with .Title }}
<figcaption>{{ . | markdownify }}</figcaption>
{{ end }}
{{ else }}
{{ errorf "resource %q not found" . }}
{{ end }}
{{ else }}
{{ .Inner }}
{{ with .Get "caption" }}
<figcaption>{{ . | markdownify }}</figcaption>
{{ end }}
{{ end }}
</figure>

View File

@ -1,14 +0,0 @@
{{/* https://github.com/gohugoio/hugo/issues/13823#issuecomment-3015270202 */}}
{{ with .Get 0 -}}
{{ with $.Page.GetPage . -}}
{{ .RenderShortcodes -}}
{{ else with $.Page.Resources.Get . -}}
{{ .RenderShortcodes -}}
{{ else with resources.Get . -}}
{{ .Content -}}
{{ else -}}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position -}}
{{ end -}}
{{ else -}}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position -}}
{{ end -}}

View File

@ -1,9 +0,0 @@
{{ with .Get 0 }}
{{ with $.Page.Resources.Get . }}
{{ partial "embed-resource.html" . }}
{{ else }}
{{ errorf "resource %q not found" . }}
{{ end }}
{{ else }}
{{ errorf "resource name not provided as first parameter" }}
{{ end }}

View File

@ -1 +0,0 @@
{{ (print .Title "'s Posts | " .Site.Title) | plainify }}

View File

@ -1 +0,0 @@
{{ (print .Title " | " .Site.Title) | plainify }}

View File

@ -1 +0,0 @@
{{ .Site.Title | plainify }}

View File

@ -0,0 +1,28 @@
{{ $hidecaption := index . "hidecaption" }}
{{ if index . "noborder" }}
<figure>
{{ else }}
<figure class="border">
{{ end }}
{{ with index . "src" }}
{{ $media := . }}
{{ if eq .MediaType.MainType "image" }}
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" loading="lazy" />
{{ else if eq .MediaType.MainType "video" }}
<video controls preload="metadata">
<source src="{{ $media.Permalink }}" alt="{{ $media.Title }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ end }}
{{ if not $hidecaption }}
{{ with $media.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
{{ end }}
{{ end }}
</figure>

View File

@ -16,6 +16,9 @@
{{ with resources.Get "js/bobatheme.js" | fingerprint "sha512" }}
<script defer src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ with resources.Get "js/share-event.js" | fingerprint "sha512" }}
<script defer src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ with .Site.Params.faviconSVG }}
<link rel="icon" href="{{ . | absURL }}" />
@ -24,7 +27,11 @@
<link rel="apple-touch-icon" href="{{ . | absURL }}" />
{{ end }}
<title>{{ .Render "head_title" }}</title>
{{ if .IsHome }}
<title>{{ .Site.Title | plainify }}</title>
{{ else }}
<title>{{ (print .Title " | " .Site.Title) | plainify }}</title>
{{ end }}
{{ partial "seo-tags/opengraph.html" . }}
{{ partial "seo-tags/twitter-cards.html" . }}

View File

@ -1,6 +1,6 @@
{{- $icon_resource := resources.Get (printf "jam/icons/%s.svg" .) -}}
{{- $icon := $icon_resource.Content -}}
{{- $icon = replaceRE `<svg` (printf `<svg class="icon icon-%s"` .) $icon -}}
{{- $icon = replaceRE `<svg` `<svg class="icon"` $icon -}}
{{- $icon = replaceRE `</svg>` (printf `<title>%s icon</title></svg>` .) $icon -}}
{{- $icon = replaceRE `(width|height)="[0-9]*"` "" $icon -}}
{{- $icon | safeHTML -}}

View File

@ -1,5 +1,5 @@
{{ with .Params.authors }}
<span class="page-metadata-item" data-pagefind-meta="authors" aria-label="{{ i18n "aria_post_meta_authors" }}">
<span class="page-metadata-item" aria-label="{{ i18n "aria_post_meta_authors" }}">
{{ partial "icon.html" "user-circle" }}
{{ if index $.Site.Taxonomies "authors" }}

View File

@ -4,7 +4,7 @@
{{ $categories = $categories | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="page-metadata-section categories" data-pagefind-meta="categories" aria-label="{{ i18n "aria_post_meta_categories" }}">
<div class="page-metadata-section categories" aria-label="{{ i18n "aria_post_meta_categories" }}">
{{ partial "icon.html" "folder" }}
{{ delimit $categories ", " | safeHTML }}
</div>

View File

@ -4,7 +4,7 @@
{{ $series = $series | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="page-metadata-section series" data-pagefind-meta="series" aria-label="{{ i18n "aria_post_meta_series" }}">
<div class="page-metadata-section series" aria-label="{{ i18n "aria_post_meta_series" }}">
{{ partial "icon.html" "files" }}
{{ delimit $series ", " | safeHTML }}
</div>

View File

@ -4,7 +4,7 @@
{{ $tags = $tags | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="page-metadata-section tags" data-pagefind-meta="tags" aria-label="{{ i18n "aria_post_meta_tags" }}">
<div class="page-metadata-section tags" aria-label="{{ i18n "aria_post_meta_tags" }}">
{{ partial "icon.html" "tag" }}
{{ delimit $tags ", " | safeHTML }}
</div>

View File

@ -22,8 +22,6 @@
{{ partial "page-metadata/item/edithistory.html" . }}
{{ partial "page-metadata/item/viewraw.html" . }}
{{ partial "page-metadata/custom-full.html" . }}
{{ partial "page-metadata/item/categories.html" . }}
{{ partial "page-metadata/item/tags.html" . }}

View File

@ -9,7 +9,6 @@
{{ partial "page-metadata/item/authors.html" . }}
{{ partial "page-metadata/item/readingtime.html" . }}
{{ partial "page-metadata/item/series.html" . }}
{{ partial "page-metadata/item/categories.html" . }}
{{ partial "page-metadata/item/tags.html" . }}

View File

@ -0,0 +1,28 @@
{{ $hidecaption := index . "hidecaption" }}
{{ $type := index . "type" }}
{{ $src := index . "src" }}
{{ $alt := index . "alt" }}
{{ if index . "border" }}
<figure class="border">
{{ else }}
<figure>
{{ end }}
{{ if eq $type "image" }}
<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" />
{{ else if eq $type "video" }}
<video controls preload="metadata">
<source src="{{ $src }}" alt="{{ $alt }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ end }}
{{ if not $hidecaption }}
{{ with $alt }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
{{ end }}
</figure>

View File

@ -33,7 +33,7 @@
<meta property="og:locale" content="{{ . }}">
{{ end }}
{{ with .Site.Title }}
{{ with .Site.Params.title }}
<meta property="og:site_name" content="{{ . }}">
{{ end }}

View File

@ -1,7 +1,3 @@
{{/* we do not need to duplicate what's already covered by OpenGraph tags
* see: https://demo.bbaovanc.com/test/remove-twitter-tags/blog/swapfile-guide/
* so, no twitter:image/title/description
*/}}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
@ -21,21 +17,13 @@
{{ else }}
<meta name="twitter:card" content="summary">
{{ end }}
{{ else }}
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="{{ $featured.Permalink }}">
{{ end }}
{{/* twitter:site is the site author; twitter:creator is page author
* https://developer.x.com/en/docs/x-for-websites/cards/guides/getting-started
* "Card and Content Attribution"
*/}}
<meta name="twitter:title" content="{{ .Title | plainify }}">
<meta name="twitter:description" content="{{ (partial "seo-description.html" .) | plainify }}">
{{ with .Site.Params.social.twitter }}
<meta name="twitter:site" content="@{{ . }}">
{{ end }}
{{ with .GetTerms "authors" }}
{{ range . }}
{{ with .Params.twitter }}
<meta name="twitter:creator" content="@{{ . }}">
{{ end }}
{{ end }}
{{ end }}

View File

@ -0,0 +1,15 @@
{{ $resource := .Page.Resources.GetMatch (.Get "src") }}
{{ $noborder := false }}
{{ if .Get "noborder" }}
{{ $noborder = true }}
{{ end }}
{{ $hidecaption := false }}
{{ if .Get "hidecaption" }}
{{ $hidecaption = true }}
{{ end }}
<p>
{{ partial "figure.html" (dict "src" $resource "noborder" $noborder "hidecaption" $hidecaption) }}
</p>

View File

@ -0,0 +1,20 @@
{{ $path := "" }}
{{ $markdown := false }}
{{ if .IsNamedParams }}
{{ $path = .Get "path" }}
{{ with .Get "markdown" }}
{{ $markdown = . }}
{{ end }}
{{ else }}
{{ $path = .Get 0 }}
{{ end }}
{{ with ($path | readFile) }}
{{ if $markdown }}
{{ $path | readFile | $.Page.RenderString (dict "display" "block") }}
{{ else }}
{{ $path | readFile }}
{{ end }}
{{ else }}
{{ errorf "file not found: %s" $path }}
{{ end }}

View File

@ -0,0 +1,13 @@
{{ $border := false }}
{{ if .Get "border" }}
{{ $border = true }}
{{ end }}
{{ $hidecaption := false }}
{{ if .Get "hidecaption" }}
{{ $hidecaption = true }}
{{ end }}
<p>
{{ partial "remote_figure.html" (dict "src" (.Get "src") "border" $border "hidecaption" $hidecaption "type" (.Get "type") "alt" (.Get "alt")) }}
</p>