Merge branch 'dev' into feat/image-position

This commit is contained in:
Nuno C.
2025-10-14 10:14:18 +01:00
committed by GitHub
80 changed files with 1363 additions and 1145 deletions

View File

@@ -1,10 +1,10 @@
{{ $anchor := anchorize .Anchor }}
<h{{ .Level }} class="relative group">{{ .Text | safeHTML }}
<h{{ .Level }} class="relative group">{{ .Text | safeHTML }}
<div id="{{ $anchor }}" class="anchor"></div>
{{ if .Page.Params.showHeadingAnchors | default (.Page.Site.Params.article.showHeadingAnchors | default true) }}
<span
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
<a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#{{ $anchor }}" aria-label="{{ i18n "article.anchor_label" }}">#</a>
</span>
<a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#{{ $anchor }}" aria-label="{{ i18n "article.anchor_label" }}">#</a>
</span>
{{ end }}
</h{{ .Level }}>

View File

@@ -1,56 +1,109 @@
{{ define "RenderImageSimple" -}}
<img class="my-0 rounded-md" loading="lazy" alt="{{ .alt }}" src="{{ .src }}">
{{- end }}
{{ define "RenderImageResponsive" -}}
{{- define "RenderImageSimple" -}}
{{- $imgObj := .imgObj -}}
{{- $src := .src -}}
{{- $alt := .alt -}}
<img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="{{ .alt }}"
srcset="
{{ (.resource.Resize "330x").RelPermalink }} 330w,
{{ (.resource.Resize "660x").RelPermalink }} 660w,
{{ (.resource.Resize "1280x").RelPermalink }} 1280w
"
data-zoom-src="{{ .resource.RelPermalink }}"
src="{{ .resource.RelPermalink }}">
{{- end }}
alt="{{ $alt }}"
src="{{ $src }}"
{{ with $imgObj -}}
{{ with $imgObj.Width }}width="{{ . }}"{{ end }}
{{ with $imgObj.Height }}height="{{ . }}"{{ end }}
{{- end }}>
{{- end -}}
{{ define "RenderImageCaption" -}}
{{- with .caption }}
{{- define "RenderImageResponsive" -}}
{{/* Responsive Image
The current setting sizes="(min-width: 768px) 50vw, 65vw" makes the iPhone 16 and 16 Pro
select a smaller image, while the iPhone 16 Pro Max selects a larger image.
Steps:
1. Check the media queries in the `sizes` property.
2. Find the first matching value. For example, on a mobile device with a CSS pixel width
of 390px and DPR = 3 (iPhone 13), given setting sizes="(min-width: 768px) 50vw, 100vw",
it matches the `100vw` option.
3. Calculate the optimal image size: 390 × 3 × 100% (100vw) = 1170.
4. Find the corresponding match in the `srcset`.
To make the browser select a smaller image on mobile devices
override the template and change the `sizes` property to "(min-width: 768px) 50vw, 30vw"
The sizes="auto" is valid only when loading="lazy".
*/}}
{{- $imgObj := .imgObj -}}
{{- $alt := .alt -}}
{{- $originalWidth := $imgObj.Width -}}
{{- $img800 := $imgObj -}}
{{- $img1280 := $imgObj -}}
{{- if gt $originalWidth 800 -}}
{{- $img800 = $imgObj.Resize "800x" -}}
{{- end -}}
{{- if gt $originalWidth 1280 -}}
{{- $img1280 = $imgObj.Resize "1280x" -}}
{{- end -}}
{{- $srcset := printf "%s 800w, %s 1280w" $img800.RelPermalink $img1280.RelPermalink -}}
<img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="{{ $alt }}"
{{ with $imgObj.Width }}width="{{ . }}"{{ end }}
{{ with $imgObj.Height }}height="{{ . }}"{{ end }}
src="{{ $img800.RelPermalink }}"
srcset="{{ $srcset }}"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="{{ $imgObj.RelPermalink }}">
{{- end -}}
{{- define "RenderImageCaption" -}}
{{- with .caption -}}
<figcaption>{{ . | markdownify }}</figcaption>
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- $disableImageOptimizationMD := .Page.Site.Params.disableImageOptimizationMD | default false }}
{{- $disableImageOptimizationMD := .Page.Site.Params.disableImageOptimizationMD | default false -}}
{{- $urlStr := .Destination | safeURL -}}
{{- $url := urls.Parse $urlStr -}}
{{- $altText := .Text }}
{{- $caption := .Title }}
{{- $isRemote := findRE "^(https?|data)" $url.Scheme }}
{{- $resource := "" }}
{{- $altText := .Text -}}
{{- $caption := .Title -}}
{{- $isRemote := findRE "^(https?|data)" $url.Scheme -}}
{{- $resource := "" -}}
{{- if not $isRemote }}
{{- $resource = or ($.Page.Resources.GetMatch $urlStr) (resources.Get $urlStr) }}
{{- end }}
{{- if not $isRemote -}}
{{- $resource = or ($.Page.Resources.GetMatch $urlStr) (resources.Get $urlStr) -}}
{{- end -}}
<figure>
{{- if $isRemote }}
{{ template "RenderImageSimple" (dict "src" $urlStr "alt" $altText) }}
{{- else if $resource }}
{{- $isSVG := eq $resource.MediaType.SubType "svg" }}
{{- $shouldOptimize := and (not $disableImageOptimizationMD) (not $isSVG) }}
{{- if $shouldOptimize }}
{{ template "RenderImageResponsive" (dict "resource" $resource "alt" $altText) }}
{{- else }}
{{ template "RenderImageSimple" (dict "src" $resource.RelPermalink "alt" $altText) }}
{{- end }}
{{- else }}
{{ template "RenderImageSimple" (dict "src" $urlStr "alt" $altText) }}
{{- end }}
{{- if $isRemote -}}
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $urlStr "alt" $altText) -}}
{{- else if $resource -}}
{{- $isSVG := eq $resource.MediaType.SubType "svg" -}}
{{- $shouldOptimize := and (not $disableImageOptimizationMD) (not $isSVG) -}}
{{- if $shouldOptimize -}}
{{- template "RenderImageResponsive" (dict "imgObj" $resource "alt" $altText) -}}
{{- else -}}
{{/* Not optimize image
If it is an SVG file, pass the permalink
Otherwise, pass the resource to allow width and height attributes
*/}}
{{- if $isSVG -}}
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $resource.RelPermalink "alt" $altText) -}}
{{- else -}}
{{- template "RenderImageSimple" (dict "imgObj" $resource "src" $resource.RelPermalink "alt" $altText) -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $urlStr "alt" $altText) -}}
{{- end -}}
{{ template "RenderImageCaption" (dict "caption" $caption) }}
{{- template "RenderImageCaption" (dict "caption" $caption) -}}
</figure>

View File

@@ -8,9 +8,10 @@
{{- partial "head.html" . -}}
{{- partialCached "init.html" . -}}
<body
class="flex flex-col h-screen px-6 m-auto text-lg leading-7 max-w-7xl bg-neutral text-neutral-900 dark:bg-neutral-800 dark:text-neutral sm:px-14 md:px-24 lg:px-32 scrollbar-thin scrollbar-track-neutral-200 scrollbar-thumb-neutral-400 dark:scrollbar-track-neutral-800 dark:scrollbar-thumb-neutral-600">
{{ $bodyLayout := "flex flex-col h-screen m-auto leading-7 max-w-7xl px-6 sm:px-14 md:px-24 lg:px-32" }}
{{ $bodyColor := "text-lg bg-neutral text-neutral-900 dark:bg-neutral-800 dark:text-neutral" }}
{{ $bodyScrollbar := "scrollbar-thin scrollbar-track-neutral-200 scrollbar-thumb-neutral-400 dark:scrollbar-track-neutral-800 dark:scrollbar-thumb-neutral-600" }}
<body class="{{ $bodyLayout }} {{ $bodyColor }} {{ $bodyScrollbar }}">
<div id="the-top" class="absolute flex self-center">
<a
class="px-3 py-1 text-sm -translate-y-8 rounded-b-lg bg-primary-200 focus:translate-y-0 dark:bg-neutral-600"
@@ -28,7 +29,7 @@
<div class="relative flex flex-col grow">
<main id="main-content" class="grow">
{{ block "main" . }}{{ end }}
{{ if and (site.Params.footer.showScrollToTop | default true) (gt .WordCount 1) }}
{{ if and (site.Params.footer.showScrollToTop | default true) }}
{{- partial "scroll-to-top.html" . -}}
{{ end }}
</main>

View File

@@ -31,19 +31,16 @@
{{/* Body */}}
<section class="flex flex-col max-w-full mt-0 prose dark:prose-invert lg:flex-row">
{{ $enableToc := .Params.showTableOfContents | default (site.Params.list.showTableOfContents | default false) }}
{{ $enableToc := site.Params.article.showTableOfContents | default false }}
{{ $enableToc = .Params.showTableOfContents | default $enableToc }}
{{ $showToc := and $enableToc (in .TableOfContents "<ul") }}
{{ $showRelated := site.Params.article.showRelatedPosts | default false }}
{{ $topClass := cond (hasPrefix site.Params.header.layout "fixed") "lg:top-[140px]" "lg:top-10" }}
{{ if or $showToc $showRelated }}
<div class="order-first lg:ml-auto px-0 lg:order-last lg:ps-8">
{{ if $showToc }}
<div class="order-first lg:ml-auto px-0 lg:order-last lg:ps-8 lg:max-w-2xs">
<div class="toc ps-5 print:hidden lg:sticky {{ $topClass }}">
{{ if $showToc }}
{{ partial "toc.html" . }}
{{ end }}
{{ if $showRelated }}
sd
{{ end }}
</div>
</div>
{{ end }}

View File

@@ -1,6 +1,6 @@
{{ define "main" }}
{{ .Scratch.Set "scope" "list" }}
{{ $showHero := .Params.showHero | default site.Params.term.showHero | default false }}
{{ $showHero := .Params.showHero | default site.Params.taxonomy.showHero | default false }}
{{ if $showHero }}
{{ $heroStyle := print "hero/" site.Params.taxonomy.heroStyle ".html" }}
{{ if templates.Exists ( printf "partials/%s" $heroStyle ) }}

View File

@@ -1,12 +1,12 @@
{{ with site.Params.fathomAnalytics.site }}
{{ partial "analytics/fathom.html" }}
{{ if site.Params.fathomAnalytics.site }}
{{ partial "analytics/fathom.html" . }}
{{ end }}
{{ with site.Config.Services.GoogleAnalytics.ID }}
{{ partial "analytics/ga.html" }}
{{ if site.Config.Services.GoogleAnalytics.ID }}
{{ partial "analytics/ga.html" . }}
{{ end }}
{{ with site.Params.umamiAnalytics.websiteid }}
{{ partial "analytics/umami.html" }}
{{ if site.Params.umamiAnalytics.websiteid }}
{{ partial "analytics/umami.html" . }}
{{ end }}
{{ with site.Params.selineAnalytics.token }}
{{ partial "analytics/seline.html" }}
{{ if site.Params.selineAnalytics.token }}
{{ partial "analytics/seline.html" . }}
{{ end }}

View File

@@ -19,8 +19,8 @@
{{ if site.Params.list.showCards }}
{{ $cardClasses = printf "%s overflow-hidden rounded-md border-2 border-neutral-200 dark:border-neutral-700" $cardClasses }}
{{ $imgWrapperClasses = "" }}
{{ $cardContentClasses = printf "%s p-2.5 pl-4 pb-0" $cardContentClasses }}
{{ $figureClasses = "" }}
{{ $cardContentClasses = printf "%s p-4 pt-2" $cardContentClasses }}
{{ else }}
{{ $cardClasses = printf "%s" $cardClasses }}
{{ $imgWrapperClasses = printf "%s thumbnail-shadow md:mr-7" $imgWrapperClasses }}
@@ -85,7 +85,7 @@
<div class="flex-none relative overflow-hidden {{ $imgWrapperClasses }} thumbnail">
<img
src="{{ . }}"
alt=""
alt="{{ with $target.Params.featuredImageAlt }}{{ . }}{{ else }}{{ $target.Title | emojify }}{{ end }}"
loading="lazy"
decoding="async"
class="not-prose absolute inset-0 w-full h-full object-cover">

View File

@@ -56,7 +56,7 @@
<div class="flex-none relative overflow-hidden thumbnail_card_related">
<img
src="{{ . }}"
alt=""
alt="{{ $page.Title }}"
loading="lazy"
decoding="async"
fetchpriority="low"

View File

@@ -60,7 +60,7 @@
<div class="flex-none relative overflow-hidden thumbnail_card">
<img
src="{{ . }}"
alt=""
alt="{{ $page.Title | plainify }}"
loading="lazy"
decoding="async"
class="not-prose absolute inset-0 w-full h-full object-cover">

View File

@@ -78,7 +78,7 @@
<div class="flex-none relative overflow-hidden {{ $imgWrapperClasses }} thumbnail">
<img
src="{{ . }}"
alt=""
alt="{{ $.Params.featuredImageAlt | default ($.Title | emojify) }}"
loading="lazy"
decoding="async"
class="not-prose absolute inset-0 w-full h-full object-cover">

View File

@@ -9,52 +9,36 @@
<div class="pt-8">
<hr class="border-dotted border-neutral-300 dark:border-neutral-600">
<div class="flex justify-between pt-3">
<span>
<span class="flex flex-col">
{{ if $prev }}
<a class="flex group mr-3" href="{{ $prev.RelPermalink }}">
<span
class="mr-3 text-neutral-700 group-hover:text-primary-600 ltr:inline rtl:hidden dark:text-neutral dark:group-hover:text-primary-400"
>&larr;</span
>
<span
class="ml-3 text-neutral-700 group-hover:text-primary-600 ltr:hidden rtl:inline dark:text-neutral dark:group-hover:text-primary-400"
>&rarr;</span
>
<span class="flex flex-col">
<span class="mt-[0.1rem] leading-6 group-hover:underline group-hover:decoration-primary-500"
>{{ $prev.Title | emojify }}</span
>
<span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" $prev.Date }}
{{ end }}
</span>
<a
class="flex text-neutral-700 hover:text-primary-600 dark:text-neutral dark:hover:text-primary-400"
href="{{ $prev.RelPermalink }}">
<span class="leading-6">
<span class="inline-block rtl:rotate-180">&larr;</span>&ensp;{{ $prev.Title | emojify }}
</span>
</a>
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
<span class="ms-6 mt-1 text-xs text-neutral-500 dark:text-neutral-400">
{{ partial "meta/date.html" $prev.Date }}
</span>
{{ end }}
{{ end }}
</span>
<span>
<span class="flex flex-col items-end">
{{ if $next }}
<a class="flex text-right group ml-3" href="{{ $next.RelPermalink }}">
<span class="flex flex-col">
<span class="mt-[0.1rem] leading-6 group-hover:underline group-hover:decoration-primary-500"
>{{ $next.Title | emojify }}</span
>
<span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" $next.Date }}
{{ end }}
</span>
<a
class="flex text-right text-neutral-700 hover:text-primary-600 dark:text-neutral dark:hover:text-primary-400"
href="{{ $next.RelPermalink }}">
<span class="leading-6">
{{ $next.Title | emojify }}&ensp;<span class="inline-block rtl:rotate-180">&rarr;</span>
</span>
<span
class="ml-3 text-neutral-700 group-hover:text-primary-600 ltr:inline rtl:hidden dark:text-neutral dark:group-hover:text-primary-400"
>&rarr;</span
>
<span
class="mr-3 text-neutral-700 group-hover:text-primary-600 ltr:hidden rtl:inline dark:text-neutral dark:group-hover:text-primary-400"
>&larr;</span
>
</a>
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
<span class="me-6 mt-1 text-xs text-neutral-500 dark:text-neutral-400">
{{ partial "meta/date.html" $next.Date }}
</span>
{{ end }}
{{ end }}
</span>
</div>

View File

@@ -8,14 +8,16 @@
{{ $authorImage = resources.Get . }}
{{ end }}
{{ if $authorImage }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill "192x192" }}
{{ $final = $authorImage.Fill "192x192" }}
{{ end }}
<img
class="!mt-0 !mb-0 h-24 w-24 rounded-full me-4"
width="96"
height="96"
src="{{ $authorImage.RelPermalink }}">
src="{{ $final.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ end }}
{{ end }}
<div class="place-self-center">

View File

@@ -8,26 +8,30 @@
{{ $authorImage = resources.Get . }}
{{ end }}
{{ if $authorImage }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill "192x192" }}
{{ $final = $authorImage.Fill "192x192" }}
{{ end }}
<img
class="!mt-0 !mb-0 h-24 w-24 rounded-full me-4"
width="96"
height="96"
alt="{{ $.Site.Params.Author.name | default " Author" }}"
src="{{ $authorImage.RelPermalink }}">
src="{{ $final.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ else }}
{{ $authorImage := resources.GetRemote . }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill "192x192" }}
{{ $final = $authorImage.Fill "192x192" }}
{{ end }}
<img
class="!mt-0 !mb-0 h-24 w-24 rounded-full me-4"
width="96"
height="96"
alt="{{ $.Site.Params.Author.name | default " Author" }}"
src="{{ $authorImage.RelPermalink }}">
src="{{ $authorImage.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ end }}
{{ end }}
<div class="place-self-center">

View File

@@ -11,7 +11,7 @@
{{ end }}
{{ $navClass := printf "flex flex-row pb-4 text-base font-medium text-neutral-500 dark:text-neutral-400 %s" (cond $onlyIcon "overflow-x-auto py-2" "") }}
{{ $ulClass := printf "flex list-none %s" (cond $onlyIcon "flex-row" "flex-col sm:flex-row") }}
{{ $liClass := printf "flex mb-1 text-end sm:mb-0 sm:me-7 sm:last:me-0 %s" (cond $onlyIcon "ltr:mr-4 rtl:ml-4" "") }}
{{ $liClass := printf "flex mb-1 text-end sm:mb-0 sm:me-7 sm:last:me-0 %s" (cond $onlyIcon "me-4" "") }}
<nav class="{{ $navClass }}">
<ul class="{{ $ulClass }}">
{{ range .Site.Menus.footer }}

View File

@@ -8,21 +8,21 @@
<meta name="theme-color">
{{/* Title */}}
{{ if .IsHome -}}
{{ if .IsHome }}
<title>{{ .Site.Title | emojify }}</title>
<meta name="title" content="{{ .Site.Title | emojify }}">
{{- else -}}
{{ else }}
<title>{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}</title>
<meta name="title" content="{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}">
{{- end }}
{{ end }}
{{/* Metadata */}}
{{ with (.Params.Summary | default .Params.Description) | default .Site.Params.description -}}
{{ with (.Params.Summary | default .Params.Description) | default .Site.Params.description }}
<meta name="description" content="{{ . }}">
{{- end }}
{{ with .Params.Tags | default .Site.Params.keywords -}}
<meta name="keywords" content="{{ range . }}{{ . }},{{ end -}}">
{{- end }}
{{ end }}
{{ with .Params.Tags | default .Site.Params.keywords }}
<meta name="keywords" content="{{ range . }}{{ . }},{{ end }}">
{{ end }}
{{ with .Site.Params.robots }}
<meta name="robots" content="{{ . }}">
{{ end }}
@@ -30,112 +30,51 @@
<meta name="robots" content="{{ . }}">
{{ end }}
<link rel="canonical" href="{{ .Permalink }}">
{{ range .AlternativeOutputFormats -}}
{{ range .AlternativeOutputFormats }}
{{ printf `
<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink ($.Site.Title | emojify) |
safeHTML
}}
{{ end -}}
{{/* Asset bundles */}}
{{ $assets := newScratch }}
{{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (.Site.Params.colorScheme | default "blowfish")) }}
{{ if not $cssScheme }}
{{ $cssScheme = resources.Get "css/schemes/blowfish.css" }}
{{ end }}
{{ $assets.Add "css" (slice $cssScheme) }}
{{ $cssMain := resources.Get "css/compiled/main.css" }}
{{ $assets.Add "css" (slice $cssMain) }}
{{ $cssCustom := resources.Get "css/custom.css" }}
{{ if $cssCustom }}
{{ $assets.Add "css" (slice $cssCustom) }}
{{ end }}
{{ if not .Site.Params.disableImageZoom | default true }}
{{ $cssZoom := resources.Get "lib/zoom/style.css" }}
{{ $assets.Add "css" (slice $cssZoom) }}
{{ end }}
{{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint
(.Site.Params.fingerprintAlgorithm | default "sha512")
}}
<link
type="text/css"
rel="stylesheet"
href="{{ $bundleCSS.RelPermalink }}"
integrity="{{ $bundleCSS.Data.Integrity }}">
{{ $jsAppearance := resources.Get "js/appearance.js" }}
{{ $jsAppearance = $jsAppearance | resources.ExecuteAsTemplate "js/appearance.js" . | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
type="text/javascript"
src="{{ $jsAppearance.RelPermalink }}"
integrity="{{ $jsAppearance.Data.Integrity }}"></script>
{{ if site.Params.footer.showScrollToTop | default true }}
{{ $jsToTop := resources.Get "js/scroll-to-top.js" }}
{{ $assets.Add "js" (slice $jsToTop) }}
{{ end }}
{{ if .Site.Params.enableA11y | default false }}
{{ $jsA11y := resources.Get "js/a11y.js" }}
{{ $jsA11y = $jsA11y | resources.Minify | resources.Fingerprint (site.Params.fingerprintAlgorithm | default "sha512") }}
<script src="{{ $jsA11y.RelPermalink }}" integrity="{{ $jsA11y.Data.Integrity }}"></script>
{{ end }}
{{ $shouldIncludeZenMode := or (.Site.Params.enableA11y | default false) (.Params.showZenMode | default (.Site.Params.article.showZenMode | default false)) }}
{{ if and .IsPage $shouldIncludeZenMode }}
{{ $jsZenMode := resources.Get "js/zen-mode.js" }}
{{ $jsZenMode = $jsZenMode | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
type="text/javascript"
src="{{ $jsZenMode.RelPermalink }}"
integrity="{{ $jsZenMode.Data.Integrity }}"></script>
{{ end }}
{{ if site.Params.footer.showScrollToTop | default true }}
{{ $jsToTop := resources.Get "js/scroll-to-top.js" }}
{{ $assets.Add "js" (slice $jsToTop) }}
{{ end }}
{{ if .Site.Params.enableSearch | default false }}
{{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }}
{{ $jsSearch := resources.Get "js/search.js" }}
{{ $assets.Add "js" (slice $jsFuse $jsSearch) }}
{{ end }}
{{ if .Site.Params.enableCodeCopy | default false }}
{{ $jsCode := resources.Get "js/code.js" }}
{{ $assets.Add "js" (slice $jsCode) }}
{{ end }}
{{ if .Site.Params.rtl | default false }}
{{ $jsRTL := resources.Get "js/rtl.js" }}
{{ $assets.Add "js" (slice $jsRTL) }}
{{ end }}
{{ $jsMobileMenu := resources.Get "js/mobilemenu.js" }}
{{ $assets.Add "js" (slice $jsMobileMenu) }}
{{ $buttonLikes := resources.Get "js/button-likes.js" }}
{{ $assets.Add "js" (slice $buttonLikes) }}
{{ $katexRender := resources.Get "js/katex-render.js" }}
{{ $assets.Add "js" (slice $katexRender) }}
{{ if $assets.Get "js" }}
{{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint
(.Site.Params.fingerprintAlgorithm | default "sha512")
}}
<script
defer
type="text/javascript"
id="script-bundle"
src="{{ $bundleJS.RelPermalink }}"
integrity="{{ $bundleJS.Data.Integrity }}"
data-copy="{{ i18n "code.copy" }}"
data-copied="{{ i18n "code.copied" }}"></script>
{{ end }}
{{ if not .Site.Params.disableImageZoom | default true }}
{{ $zoomJS := resources.Get "lib/zoom/zoom.min.umd.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script src="{{ $zoomJS.RelPermalink }}" integrity="{{ $zoomJS.Data.Integrity }}"></script>
{{ end }}
{{/* Icons */}}
{{ if templates.Exists "partials/favicons.html" }}
{{ partialCached "favicons.html" .Site }}
{{ else }}
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}">
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}">
{{/* Me */}}
{{ with .Site.Params.Author.name }}
<meta name="author" content="{{ . }}">
{{ end }}
{{ with .Site.Params.Author.links }}
{{ range $links := . }}
{{ range $name, $url := $links }}
{{ if not (strings.HasPrefix $url "mailto:") }}
<link href="{{ $url }}" rel="me">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Social */}}
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{/* Use defaultSocialImage if feature image does not exist */}}
{{ $featureImage := "" }}
{{ $pageImages := .Resources.ByType "image" }}
{{ range slice "*featured*" "*cover*" "*thumbnail*" }}
{{ if not $featureImage }}
{{ $featureImage = $pageImages.GetMatch . }}
{{ end }}
{{ end }}
{{ if not $featureImage }}
{{ with .Site.Params.defaultSocialImage }}
{{ $socialImage := "" }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $socialImage = resources.GetRemote . }}
{{ else }}
{{ $socialImage = resources.Get . }}
{{ end }}
{{ with $socialImage }}
<meta name="twitter:image" content="{{ .RelPermalink | absURL }}">
<meta property="og:image" content="{{ .RelPermalink | absURL }}">
{{ end }}
{{ end }}
{{ end }}
{{/* Site Verification */}}
@@ -155,52 +94,101 @@
<meta name="fediverse:creator" content="{{ . }}">
{{ end }}
{{/* Social */}}
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{ $alg := .Site.Params.fingerprintAlgorithm | default "sha512" }}
{{- /* Main page always uses this; fallback elsewhere if no feature image */ -}}
{{- /* See https://gohugo.io/templates/embedded/#open-graph */ -}}
{{- $images := .Resources.ByType "image" -}}
{{- $socialImage := $images.GetMatch "*feature*" -}}
{{/* CSS */}}
{{ $cssResources := slice }}
{{ $schemeName := .Site.Params.colorScheme | default "blowfish" }}
{{ $cssScheme := resources.Get (printf "css/schemes/%s.css" $schemeName) | default (resources.Get "css/schemes/blowfish.css") }}
{{ $cssResources = $cssResources | append $cssScheme }}
{{ $cssResources = $cssResources | append (resources.Get "css/compiled/main.css") }}
{{ with resources.Get "css/custom.css" }}
{{ $cssResources = $cssResources | append . }}
{{ end }}
{{ if not .Site.Params.disableImageZoom | default true }}
{{ $cssResources = $cssResources | append (resources.Get "lib/zoom/style.css") }}
{{ end }}
{{ $bundleCSS := $cssResources | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint $alg }}
<link
type="text/css"
rel="stylesheet"
href="{{ $bundleCSS.RelPermalink }}"
integrity="{{ $bundleCSS.Data.Integrity }}">
{{- if not $socialImage -}}
{{- with .Site.Params.defaultSocialImage -}}
{{- if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") -}}
{{- $socialImage = resources.GetRemote . -}}
{{- else -}}
{{- $socialImage = resources.Get . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/* JS loaded immediately */}}
{{ $jsAppearance := resources.Get "js/appearance.js" | resources.ExecuteAsTemplate "js/appearance.js" . | resources.Minify | resources.Fingerprint $alg }}
<script
type="text/javascript"
src="{{ $jsAppearance.RelPermalink }}"
integrity="{{ $jsAppearance.Data.Integrity }}"></script>
{{ $enableA11y := .Site.Params.enableA11y | default false }}
{{ if $enableA11y }}
{{ $jsA11y := resources.Get "js/a11y.js" | resources.Minify | resources.Fingerprint $alg }}
<script src="{{ $jsA11y.RelPermalink }}" integrity="{{ $jsA11y.Data.Integrity }}"></script>
{{ end }}
{{ $showZenMode := .Params.showZenMode | default (.Site.Params.article.showZenMode | default false) }}
{{ $shouldIncludeZenMode := or $enableA11y $showZenMode }}
{{ if and .IsPage $shouldIncludeZenMode }}
{{ $jsZenMode := resources.Get "js/zen-mode.js" | resources.Minify | resources.Fingerprint $alg }}
<script
type="text/javascript"
src="{{ $jsZenMode.RelPermalink }}"
integrity="{{ $jsZenMode.Data.Integrity }}"></script>
{{ end }}
{{ if not .Site.Params.disableImageZoom | default true }}
{{ $zoomJS := resources.Get "lib/zoom/zoom.min.umd.js" | resources.Fingerprint $alg }}
<script src="{{ $zoomJS.RelPermalink }}" integrity="{{ $zoomJS.Data.Integrity }}"></script>
{{ end }}
{{- with $socialImage -}}
<meta name="twitter:image" content="{{ .RelPermalink | absURL }}">
<meta property="og:image" content="{{ .RelPermalink | absURL }}">
{{- end -}}
{{/* JS deferred */}}
{{ $jsResources := slice }}
{{ if site.Params.footer.showScrollToTop | default true }}
{{ $jsResources = $jsResources | append (resources.Get "js/scroll-to-top.js") }}
{{ end }}
{{ if .Site.Params.enableSearch | default false }}
{{ $jsResources = $jsResources | append (resources.Get "lib/fuse/fuse.min.js") | append (resources.Get "js/search.js") }}
{{ end }}
{{ if .Site.Params.enableCodeCopy | default false }}
{{ $jsResources = $jsResources | append (resources.Get "js/code.js") }}
{{ end }}
{{ if .Site.Params.rtl | default false }}
{{ $jsResources = $jsResources | append (resources.Get "js/rtl.js") }}
{{ end }}
{{ $jsResources = $jsResources | append (resources.Get "js/mobilemenu.js") }}
{{ $jsResources = $jsResources | append (resources.Get "js/button-likes.js") }}
{{ $jsResources = $jsResources | append (resources.Get "js/katex-render.js") }}
{{ if $jsResources }}
{{ $bundleJS := $jsResources | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint $alg }}
<script
defer
type="text/javascript"
id="script-bundle"
src="{{ $bundleJS.RelPermalink }}"
integrity="{{ $bundleJS.Data.Integrity }}"
data-copy="{{ i18n "code.copy" }}"
data-copied="{{ i18n "code.copied" }}"></script>
{{ end }}
{{/* Conditional loaded resources */}}
{{ partial "vendor.html" . }}
{{/* Icons */}}
{{ if templates.Exists "partials/favicons.html" }}
{{ partialCached "favicons.html" .Site }}
{{ else }}
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}">
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}">
{{ end }}
{{/* Schema */}}
{{ partial "schema.html" . }}
{{/* Me */}}
{{ with .Site.Params.Author.name }}
<meta name="author" content="{{ . }}">
{{ end }}
{{ with .Site.Params.Author.links }}
{{ range $links := . }}
{{ range $name, $url := $links }}
{{ if not (strings.HasPrefix $url "mailto:") }}
<link href="{{ $url }}" rel="me">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Vendor */}}
{{ partial "vendor.html" . }}
{{/* Analytics */}}
{{ partial "analytics/main.html" .Site }}
{{ if hugo.IsProduction }}
{{ partial "analytics/main.html" . }}
{{ end }}
{{/* Extend head - eg. for custom analytics scripts, etc. */}}
{{ if templates.Exists "partials/extend-head.html" }}
@@ -218,11 +206,11 @@
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-auth.js"></script>
<script>
<script>
const firebaseConfig = {
apiKey: {{ $.Site.Params.firebase.apiKey }},
authDomain: {{ $.Site.Params.firebase.apiKey }},
authDomain: {{ $.Site.Params.firebase.authDomain }},
projectId: {{ $.Site.Params.firebase.projectId }},
storageBucket: {{ $.Site.Params.firebase.storageBucket }},
messagingSenderId: {{ $.Site.Params.firebase.messagingSenderId }},
@@ -230,18 +218,20 @@
measurementId: {{ $.Site.Params.firebase.measurementId }}
};
var app = firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();
var auth = firebase.auth();
var app = firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();
var auth = firebase.auth();
</script>
</script>
{{ end }}
{{ end }}
{{/* Advertisement */}}
{{ with .Site.Params.advertisement.adsense }}
<meta name="google-adsense-account" content="{{ . }}">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ . }}"
crossorigin="anonymous"></script>
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ . }}"
crossorigin="anonymous"></script>
{{ end }}
</head>

View File

@@ -16,7 +16,7 @@
width="{{ div $logo.Width 2 }}"
height="{{ div $logo.Height 2 }}"
class="logo max-h-[5rem] max-w-[5rem] object-scale-down object-left nozoom"
alt="{{ .Site.Title }}">
alt="">
{{ end }}
</a>
</div>
@@ -68,7 +68,7 @@
{{ end }}
{{/* Mobile navigation */}}
{{ define "HeaderMobileNavigation" }}
{{ define "HeaderMobileToolbar" }}
<div class="flex md:hidden items-center gap-x-5 md:ml-12 h-12">
<span></span>
@@ -104,7 +104,7 @@
</div>
{{ end }}
{{ define "HeaderMobileMenu" }}
{{ define "HeaderMobileNavigation" }}
<div class="-my-2 md:hidden">
<div id="menu-button" class="block">
{{ if .Site.Menus.main }}
@@ -243,7 +243,7 @@
{{/* ========== Render HTML ========== */}}
<div
class="main-menu flex items-center justify-between px-4 py-6 sm:px-6 md:justify-start gap-x-3 pt-[2px] pr-0 pb-[3px] pl-0">
class="main-menu flex items-center justify-between py-6 md:justify-start gap-x-3 pt-[2px] pr-2 md:pr-4 pb-[3px] pl-0">
{{ template "HeaderLogo" . }}
<div class="flex flex-1 items-center justify-between">
<nav class="flex space-x-3">
@@ -254,9 +254,9 @@
{{ end }}
</nav>
{{ template "HeaderDesktopNavigation" . }}
{{ template "HeaderMobileNavigation" . }}
{{ template "HeaderMobileToolbar" . }}
</div>
{{ template "HeaderMobileMenu" . }}
{{ template "HeaderMobileNavigation" . }}
</div>
{{ if .Site.Menus.subnavigation }}

View File

@@ -1,9 +1,9 @@
<div class="min-h-[148px]"></div>
<div class="fixed inset-x-0 pl-[24px] pr-[24px] z-100">
<div class="fixed inset-x-0 z-100">
<div
id="menu-blur"
class="absolute opacity-0 inset-x-0 top-0 h-full single_hero_background nozoom bg-neutral dark:bg-neutral-800"></div>
<div class="relative max-w-[64rem] ml-auto mr-auto">
<div class="relative m-auto leading-7 max-w-7xl px-6 sm:px-14 md:px-24 lg:px-32">
{{ partial "header/basic.html" . }}
</div>
</div>

View File

@@ -1,6 +1,6 @@
<div class="min-h-[148px]"></div>
<div class="fixed inset-x-0 pl-[24px] pr-[24px] bg-neutral dark:bg-neutral-800 z-100">
<div class="relative max-w-[64rem] ml-auto mr-auto">
<div class="fixed inset-x-0 bg-neutral dark:bg-neutral-800 z-100">
<div class="relative m-auto leading-7 max-w-7xl px-6 sm:px-14 md:px-24 lg:px-32">
{{ partial "header/basic.html" . }}
</div>
</div>

View File

@@ -1,11 +1,11 @@
<div class="min-h-[148px]"></div>
<div
class="fixed inset-x-0 min-h-[130px] opacity-65 pl-[24px] pr-[24px] bg-gradient-to-b from-neutral from-60% dark:from-neutral-800 to-transparent mix-blend-normal z-80"></div>
<div class="fixed inset-x-0 pl-[24px] pr-[24px] z-100">
class="fixed inset-x-0 min-h-[130px] opacity-65 bg-gradient-to-b from-neutral from-60% dark:from-neutral-800 to-transparent mix-blend-normal z-80"></div>
<div class="fixed inset-x-0 z-100">
<div
id="menu-blur"
class="absolute opacity-0 inset-x-0 top-0 h-full single_hero_background nozoom backdrop-blur-2xl shadow-2xl"></div>
<div class="relative max-w-[64rem] ml-auto mr-auto">
<div class="relative m-auto leading-7 max-w-7xl px-6 sm:px-14 md:px-24 lg:px-32">
{{ partial "header/basic.html" . }}
</div>
</div>

View File

@@ -1,9 +1,9 @@
<div class="min-h-[148px]"></div>
<div class="fixed inset-x-0 pl-[24px] pr-[24px] z-100">
<div class="fixed inset-x-0 z-100">
<div
id="menu-blur"
class="absolute opacity-0 inset-x-0 top-0 h-full single_hero_background nozoom backdrop-blur-2xl shadow-2xl"></div>
<div class="relative max-w-[64rem] ml-auto mr-auto">
<div class="relative m-auto leading-7 max-w-7xl px-6 sm:px-14 md:px-24 lg:px-32">
{{ partial "header/basic.html" . }}
</div>
</div>

View File

@@ -1,6 +1,7 @@
<li class="mt-1">
<a
href="{{ .URL }}"
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
class="flex items-center hover:text-primary-600 dark:hover:text-primary-400">
{{ if .Pre }}
<span {{ if and .Pre .Name }}class="mr-1"{{ end }}>
@@ -24,6 +25,7 @@
}}
target="_blank"
{{ end }}
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
class="flex items-center hover:text-primary-600 dark:hover:text-primary-400">
{{ if .Pre }}
<span {{ if and .Pre .Name }}class="mr-1"{{ end }}>

View File

@@ -7,6 +7,7 @@
target="_blank"
{{ end }}
class="flex items-center hover:text-primary-600 dark:hover:text-primary-400"
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
title="{{ .Title }}">
{{ if .Pre }}
<div {{ if and .Pre .Name }}class="mr-2"{{ end }}>

View File

@@ -12,6 +12,7 @@
target="_blank"
{{ end }}
{{ end }}
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
class="text-base font-medium hover:text-primary-600 dark:hover:text-primary-400"
title="{{ .Title }}">
<p>
@@ -31,6 +32,7 @@
{{ if or (strings.HasPrefix .URL "http:" ) (strings.HasPrefix .URL "https:" ) }}
target="_blank"
{{ end }}
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
class="flex items-center hover:text-primary-600 dark:hover:text-primary-400">
{{ if .Pre }}
<span {{ if and .Pre .Name }}class="mr-1"{{ end }}>

View File

@@ -2,6 +2,7 @@
href="{{ .URL }}"
{{ if or (strings.HasPrefix .URL "http:" ) (strings.HasPrefix .URL "https:" ) }}target="_blank"{{ end }}
class="flex items-center hover:text-primary-600 dark:hover:text-primary-400"
{{ with or .Name .Pre }}aria-label="{{ . }}"{{ end }}
title="{{ .Title }}">
{{ if .Pre }}
<span {{ if and .Pre .Name }}class="mr-1"{{ end }}>

View File

@@ -69,7 +69,7 @@
<img
id="background-image"
src="{{ . }}"
alt=""
alt="{{ $.Title }}"
loading="eager"
decoding="async"
fetchpriority="high"

View File

@@ -53,7 +53,7 @@
<div class="overflow-hidden h-36 md:h-56 lg:h-72">
<img
src="{{ . }}"
alt=""
alt="{{ with $.Params.featureimagealt }}{{ . }}{{ else }}{{ with $.Title }}Featured image for {{ . }}{{ else }}Featured image{{ end }}{{ end }}"
loading="eager"
decoding="async"
fetchpriority="high"

View File

@@ -87,7 +87,7 @@
<div class="overflow-hidden rounded-md h-36 md:h-56 lg:h-72 nozoom">
<img
src="{{ . }}"
alt=""
alt="{{ $.Title }}"
loading="eager"
decoding="async"
fetchpriority="high"
@@ -108,6 +108,7 @@
id="background-image-main"
src="{{ . }}"
alt=""
role="presentation"
loading="eager"
decoding="async"
fetchpriority="high"

View File

@@ -50,15 +50,17 @@
{{ $authorImage = resources.Get . }}
{{ end }}
{{ if $authorImage }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ $final = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ end }}
<img
class="mb-2 h-36 w-36 rounded-full"
width="144"
height="144"
alt="{{ $.Site.Params.Author.name | default " Author" }}"
src="{{ $authorImage.RelPermalink }}">
alt="{{ $.Site.Params.Author.name | default `Author` }}"
src="{{ $final.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ end }}
{{ end }}
<h1 class="mb-2 text-4xl font-extrabold text-neutral-800 dark:text-neutral-200">

View File

@@ -53,15 +53,17 @@
{{ $authorImage = resources.Get . }}
{{ end }}
{{ if $authorImage }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ $final = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ end }}
<img
class="mb-2 rounded-full h-36 w-36"
class="mb-2 h-36 w-36 rounded-full"
width="144"
height="144"
alt="{{ $.Site.Params.Author.name | default " Author" }}"
src="{{ $authorImage.RelPermalink }}">
alt="{{ $.Site.Params.Author.name | default `Author` }}"
src="{{ $final.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ end }}
{{ end }}
{{ if not $disableHeroImageFilter }}

View File

@@ -12,15 +12,17 @@
{{ $authorImage = resources.Get . }}
{{ end }}
{{ if $authorImage }}
{{ $final := $authorImage }}
{{ if not $disableImageOptimization }}
{{ $authorImage = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ $final = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
{{ end }}
<img
class="mb-2 rounded-full h-36 w-36"
class="mb-2 h-36 w-36 rounded-full"
width="144"
height="144"
alt="{{ $.Site.Params.Author.name | default " Author" }}"
src="{{ $authorImage.RelPermalink }}">
alt="{{ $.Site.Params.Author.name | default `Author` }}"
src="{{ $final.RelPermalink }}"
data-zoom-src="{{ $authorImage.RelPermalink }}">
{{ end }}
{{ end }}
<h1 class="text-4xl font-extrabold">

View File

@@ -19,7 +19,7 @@
{{ $showMoreLinkDest = .Site.Params.homepage.showMoreLinkDest }}
{{ end }}
<div class="mt-10 flex justify-center">
<a href="{{ $showMoreLinkDest }}">
<a href="{{ $showMoreLinkDest | relLangURL }}">
<button
class="bg-transparent hover:text-primary-500 prose dark:prose-invert font-semibold py-2 px-4 border border-primary-500 hover:border-transparent rounded">
{{ i18n "recent.show_more" | markdownify }}

View File

@@ -1,5 +1,9 @@
{{ $coffeeIsRight := and site.Params.buymeacoffee.globalWidget (eq (lower site.Params.buymeacoffee.globalWidgetPosition) "right") }}
{{ $toTopYOffset := cond $coffeeIsRight "bottom-24" "bottom-6" }}
{{ $coffeeIsRight := and .Site.Params.buymeacoffee.globalWidget (eq (lower site.Params.buymeacoffee.globalWidgetPosition) "right") }}
{{ $isRTL := .Site.Params.rtl | default false }}
{{ $needAvoidCoffee := ne $coffeeIsRight $isRTL }}
{{ $toTopYOffset := cond $needAvoidCoffee "bottom-24" "bottom-6" }}
<div
id="scroll-to-top"
class="fixed {{ $toTopYOffset }} end-6 z-50 transform translate-y-4 opacity-0 duration-200">

View File

@@ -33,12 +33,24 @@
const TOC_LINK_SELECTOR = 'a[href^="#"]'
const NESTED_LIST_SELECTOR = 'li ul'
const ACTIVE_CLASS = 'active'
let isJumpingToAnchor = false
function getActiveAnchorId(anchors, offsetRatio) {
const threshold = window.scrollY + window.innerHeight * offsetRatio
const tocLinks = [...document.querySelectorAll('#TableOfContents a[href^="#"]')]
const tocIds = new Set(tocLinks.map(link => link.getAttribute('href').substring(1)))
if (isJumpingToAnchor) {
for (let i = 0; i < anchors.length; i++) {
const anchor = anchors[i]
if (!tocIds.has(anchor.id)) continue
const top = anchor.getBoundingClientRect().top + window.scrollY
if (Math.abs(window.scrollY - top) < 100) {
return anchor.id
}
}
}
for (let i = anchors.length - 1; i >= 0; i--) {
const top = anchors[i].getBoundingClientRect().top + window.scrollY
if (top <= threshold && tocIds.has(anchors[i].id)) {
@@ -85,6 +97,12 @@
toc.querySelectorAll(NESTED_LIST_SELECTOR).forEach(ul => ul.style.display = 'none')
}
links.forEach(link => {
link.addEventListener('click', () => {
isJumpingToAnchor = true
})
})
const config = {
toc,
anchors,

View File

@@ -149,8 +149,9 @@
{{ end }}
{{ end }}
{{ $repoCardCSS := resources.FromString "css/repo-cards.css" (delimit $cssRules "\n")
| minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512")
}}
{{ $cssContent := delimit $cssRules "\n" }}
{{ $outputPath := path.Join .Page.RelPermalink "repo-cards.css" }}
{{ $repoCardCSS := resources.FromString $outputPath $cssContent | minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
<link rel="stylesheet" href="{{ $repoCardCSS.RelPermalink }}" integrity="{{ $repoCardCSS.Data.Integrity }}">
{{ end }}

View File

@@ -1,5 +1,7 @@
{{ $id := delimit (slice "carousel" (partial "functions/uid.html" .) (now.UnixNano)) "-" }}
{{ $aspect := default "16-9" (.Get "aspectRatio") }}
{{ $aspect := (split (.Get "aspectRatio") "-") }}
{{ $aspectx := default "16" (index $aspect 0) }}
{{ $aspecty := default "9" (index $aspect 1) }}
{{ $interval := default "2000" (.Get "interval") }}
{{ $page := .Page.Resources }}
@@ -47,10 +49,12 @@
data-twe-carousel-item
style="transition-duration: {{ $interval }}ms;"
{{ if eq $index 0 }}data-twe-carousel-active{{ end }}>
<div class="ratio-{{ $aspect }} single_hero_background">
<div
class="single_hero_background"
style="aspect-ratio: {{ $aspectx }} / {{ $aspecty }};">
<img
src="{{ $image.RelPermalink }}"
class="block absolute top-0 object-cover w-full h-full nozoom"
class="block absolute top-0 object-cover w-full h-full not-prose nozoom"
alt="carousel image {{ add $index 1 }}">
</div>
</div>

View File

@@ -31,14 +31,18 @@
{{- else }}
<img
class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}"
srcset="
{{ (.Resize "330x").RelPermalink }} 330w,
{{ (.Resize "660x").RelPermalink }} 660w,
{{ (.Resize "1024x").RelPermalink }} 1024w,
{{ (.Resize "1320x").RelPermalink }} 2x"
src="{{ (.Resize "660x").RelPermalink }}"
data-zoom-src="{{ (.Resize "1320x").RelPermalink }}"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="{{ $altText }}"
{{ with .Width }}width="{{ . }}"{{ end }}
{{ with .Height }}height="{{ . }}"{{ end }}
src="{{ (.Resize "800x").RelPermalink }}"
srcset="
{{- (.Resize "800x").RelPermalink }} 800w,
{{- (.Resize "1280x").RelPermalink }} 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="{{ .RelPermalink }}"
/>
{{- end }}
{{- else }}

View File

@@ -1,3 +1 @@
<div class="mermaid" align="center">
<pre>{{ .Inner | safeHTML }}</pre>
</div>
<pre class="not-prose mermaid">{{ .Inner | safeHTML }}</pre>