Skip to content

Commit

Permalink
initial support
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed May 16, 2024
1 parent e876837 commit 9e1f8f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 7 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noodp" />

{{/* View Transition */}}
{{/* https://developer.chrome.com/docs/web-platform/view-transitions/cross-document */}}
<style>
@view-transition {
navigation: auto;
}
</style>
{{- /* Paginate */ -}}
{{- /* Paginate in here, To solve the problem of the canonical URL being the same in the pagination */ -}}
{{- /* see more https://github.com/gohugoio/hugo/issues/4507 */ -}}
Expand Down
6 changes: 3 additions & 3 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
{{- with $image -}}
<div class="featured-image-preview">
<a href="{{ $.RelPermalink }}" aria-label={{ $.Title }}>
{{- dict "Src" . "Title" $.Description "Resources" $.Resources "Loading" "eager" "Optim" true | partial "plugin/image.html" -}}
{{- dict "Src" . "Title" $.Description "Resources" $.Resources "Loading" "eager" "Optim" true "ViewTransitionName" (printf "featured-image-%v" $.Title) | partial "plugin/image.html" -}}
</a>
</div>
{{- end -}}

{{- /* Title */ -}}
<h1 class="single-title">
<h1 class="single-title" style='view-transition-name: {{ (printf "single-title-%v" .Title) | partial "function/stringNormalise.html" | safeCSS }};'>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h1>

{{- /* Meta */ -}}
<div class="post-meta">
<span class="post-author">
<span class="post-author" style='view-transition-name: {{ (printf "post-author-%v" .Title) | partial "function/stringNormalise.html" | safeCSS }};'>
{{- partial "meta/author" . }}
</span>

Expand Down
1 change: 1 addition & 0 deletions layouts/partials/function/stringNormalise.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- return replaceRE "[^A-Za-z0-9]" "-" . -}}
1 change: 1 addition & 0 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{{- end -}}
<img
{{ with .Class }}class="{{ . }}"{{ end }}
{{- with .ViewTransitionName -}}style='view-transition-name: {{ . | partial "function/stringNormalise.html" | safeCSS }};'{{ end }}
loading="{{ $loading }}"
src="{{ $default.RelPermalink | safeURL }}"
srcset="
Expand Down
6 changes: 3 additions & 3 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2 class="toc-title">{{ T "contents" }}</h2>

<article class="page single print:!tw-w-full print:!tw-max-w-none print:!tw-m-0 print:!tw-p-0">
{{- /* Title */ -}}
<h1 class="single-title">{{ .Title }}</h1>
<h1 class="single-title" style='view-transition-name: {{ (printf "single-title-%v" .Title) | partial "function/stringNormalise.html" | safeCSS }};'>{{ .Title }}</h1>

{{- /* Subtitle */ -}}
{{- with $params.subtitle -}}
Expand All @@ -44,7 +44,7 @@ <h2 class="single-subtitle">{{ . }}</h2>
{{- /* Meta */ -}}
<div class="post-meta">
<div class="post-meta-line">
<span class="post-author">
<span class="post-author" style='view-transition-name: {{ (printf "post-author-%v" .Title) | partial "function/stringNormalise.html" | safeCSS }};'>
{{- partial "meta/author.html" . }}
</span>
{{- with .Params.categories | or .Params.series -}}
Expand Down Expand Up @@ -151,7 +151,7 @@ <h2 class="single-subtitle">{{ . }}</h2>
{{- $image := $params.featuredimage -}}
{{- with $image -}}
<div class="featured-image">
{{- dict "Src" . "Title" $.Description "Resources" $.Resources "Loading" "eager" "Optim" true | partial "plugin/image.html" -}}
{{- dict "Src" . "Title" $.Description "Resources" $.Resources "Loading" "eager" "Optim" true "ViewTransitionName" (printf "featured-image-%v" $.Title) | partial "plugin/image.html" -}}
</div>
{{- end -}}
{{- /* Series list */ -}}
Expand Down

0 comments on commit 9e1f8f2

Please sign in to comment.