style(article-link): run prettier format

This commit is contained in:
ZhenShuo Leo
2025-07-09 23:43:26 +08:00
parent 35faec527b
commit 2978995211
4 changed files with 155 additions and 149 deletions

View File

@@ -28,9 +28,6 @@ static
layouts/_default/_markup/render-heading.html layouts/_default/_markup/render-heading.html
layouts/_default/index.json layouts/_default/index.json
layouts/_default/list.html layouts/_default/list.html
layouts/partials/article-link/card-related.html
layouts/partials/article-link/card.html
layouts/partials/article-link/simple.html
layouts/partials/hero/background.html layouts/partials/hero/background.html
layouts/shortcodes/screenshot.html layouts/shortcodes/screenshot.html
layouts/shortcodes/figure.html layouts/shortcodes/figure.html

View File

@@ -1,44 +1,45 @@
<a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full"> <a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full">
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative"> <div
class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative">
{{- with $.Params.images -}} {{- with $.Params.images -}}
{{- range first 6 . }} {{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} <meta property="og:image" content="{{ . | absURL }}">
{{- else -}} {{ end -}}
{{ $images := $.Resources.ByType "image" }} {{- else -}}
{{ $featuredImage := $images.GetMatch "*feature*" }} {{ $images := $.Resources.ByType "image" }}
{{ if not $featuredImage }} {{ $featuredImage := $images.GetMatch "*feature*" }}
{{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ if and (not $featuredImage) .Params.featureimage }} {{ end }}
{{ $featuredImage = resources.GetRemote .Params.featureimage }} {{ if and (not $featuredImage) .Params.featureimage }}
{{ end }} {{ $featuredImage = resources.GetRemote .Params.featureimage }}
{{ if not $featuredImage }} {{ end }}
{{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ end }}
{{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ $featuredImage = $featuredImage.Resize "600x" }} {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }}
{{ end }} {{ $featuredImage = $featuredImage.Resize "600x" }}
{{ with $featuredImage }} {{ end }}
{{ $className := printf "background-image-%s" (md5 .RelPermalink) }} {{ with $featuredImage }}
<div class="w-full thumbnail_card_related nozoom {{ $className }}"></div> {{ $className := printf "background-image-%s" (md5 .RelPermalink) }}
{{ else }} <div class="w-full thumbnail_card_related nozoom {{ $className }}"></div>
{{ with $.Site.Params.images }} {{ else }}
<meta property="og:image" content="{{ index . 0 | absURL }}" /> {{ with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2"> <span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span> </span>
{{ end }} {{ end }}
<div class="px-6 py-4">
{{ with .Params.externalUrl }} <div class="px-6 py-4">
{{ with .Params.externalUrl }}
<div> <div>
<div <div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
@@ -49,23 +50,25 @@
</span> </span>
</div> </div>
</div> </div>
{{ else }} {{ else }}
<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral" <div
href="{{ .RelPermalink }}">{{ .Title | emojify }}</div> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
{{ end }} href="{{ .RelPermalink }}">
{{ .Title | emojify }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div> </div>
{{ end }}
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 prose dark:prose-invert"> <div class="py-1 prose dark:prose-invert">
{{ .Summary | plainify }} {{ .Summary | plainify }}
</div> </div>
{{ end }} {{ end }}
</div>
<div class="px-6 pt-4 pb-2">
</div>
</div> </div>
</a> <div class="px-6 pt-4 pb-2"></div>
</div>
</a>

View File

@@ -1,48 +1,48 @@
<a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full"> <a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full">
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative"> <div
class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative">
{{- with $.Params.images -}} {{- with $.Params.images -}}
{{- range first 6 . }} {{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} <meta property="og:image" content="{{ . | absURL }}">
{{- else -}} {{ end -}}
{{ $images := $.Resources.ByType "image" }} {{- else -}}
{{ $featuredImage := $images.GetMatch "*feature*" }} {{ $images := $.Resources.ByType "image" }}
{{ if not $featuredImage }} {{ $featuredImage := $images.GetMatch "*feature*" }}
{{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ if and (not $featuredImage) .Params.featureimage }} {{ end }}
{{ $featuredImage = resources.GetRemote .Params.featureimage }} {{ if and (not $featuredImage) .Params.featureimage }}
{{ end }} {{ $featuredImage = resources.GetRemote .Params.featureimage }}
{{ if not $featuredImage }} {{ end }}
{{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ end }}
{{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ $featuredImage = $featuredImage.Resize "600x" }} {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }}
{{ end }} {{ $featuredImage = $featuredImage.Resize "600x" }}
{{ if .Params.hideFeatureImage }} {{ end }}
{{ $featuredImage = false }} {{ if .Params.hideFeatureImage }}
{{ end }} {{ $featuredImage = false }}
{{ with $featuredImage }} {{ end }}
{{ $className := printf "background-image-%s" (md5 .RelPermalink) }} {{ with $featuredImage }}
<div class="w-full thumbnail_card nozoom {{ $className }}"></div> {{ $className := printf "background-image-%s" (md5 .RelPermalink) }}
{{ else }} <div class="w-full thumbnail_card nozoom {{ $className }}"></div>
{{ with $.Site.Params.images }} {{ else }}
<meta property="og:image" content="{{ index . 0 | absURL }}" /> {{ with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2"> <span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span> </span>
{{ end }} {{ end }}
<div class="px-6 py-4">
{{ with .Params.externalUrl }} <div class="px-6 py-4">
{{ with .Params.externalUrl }}
<div> <div>
<div <div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
@@ -53,23 +53,25 @@
</span> </span>
</div> </div>
</div> </div>
{{ else }} {{ else }}
<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral" <div
href="{{ .RelPermalink }}">{{ .Title | emojify }}</div> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
{{ end }} href="{{ .RelPermalink }}">
{{ .Title | emojify }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div> </div>
{{ end }}
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 prose dark:prose-invert"> <div class="py-1 prose dark:prose-invert">
{{ .Summary | plainify }} {{ .Summary | plainify }}
</div> </div>
{{ end }} {{ end }}
</div>
<div class="px-6 pt-4 pb-2">
</div>
</div> </div>
</a> <div class="px-6 pt-4 pb-2"></div>
</div>
</a>

View File

@@ -2,67 +2,68 @@
{{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }} {{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }}
{{ if .Site.Params.list.showCards }} {{ if .Site.Params.list.showCards }}
{{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }} {{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }}
{{ else }} {{ else }}
{{ $articleClasses = delimit (slice $articleClasses "") " " }} {{ $articleClasses = delimit (slice $articleClasses "") " " }}
{{ end }} {{ end }}
{{ $articleImageClasses := "w-full md:w-auto h-full thumbnail nozoom" }} {{ $articleImageClasses := "w-full md:w-auto h-full thumbnail nozoom" }}
{{ if .Site.Params.list.showCards }} {{ if .Site.Params.list.showCards }}
{{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }} {{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }}
{{ else }} {{ else }}
{{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }} {{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }}
{{ end }} {{ end }}
{{ $articleInnerClasses := "" }} {{ $articleInnerClasses := "" }}
{{ if .Site.Params.list.showCards }} {{ if .Site.Params.list.showCards }}
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }} {{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }}
{{ else }} {{ else }}
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }} {{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }}
{{ end }} {{ end }}
{{ if $constrainItemsWidth }} {{ if $constrainItemsWidth }}
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }} {{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
{{ end }} {{ end }}
<a class="{{ $articleClasses }}" {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}> <a class="{{ $articleClasses }}" {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}>
{{- with $.Params.images -}} {{- with $.Params.images -}}
{{- range first 6 . }} {{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} <meta property="og:image" content="{{ . | absURL }}">
{{- else -}} {{ end -}}
{{ $images := $.Resources.ByType "image" }} {{- else -}}
{{ $featuredImage := $images.GetMatch "*feature*" }} {{ $images := $.Resources.ByType "image" }}
{{ if not $featuredImage }} {{ $featuredImage := $images.GetMatch "*feature*" }}
{{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ if and (not $featuredImage) .Params.featureimage }} {{ end }}
{{ $featuredImage = resources.GetRemote .Params.featureimage }} {{ if and (not $featuredImage) .Params.featureimage }}
{{ end }} {{ $featuredImage = resources.GetRemote .Params.featureimage }}
{{ if not $featuredImage }} {{ end }}
{{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} {{ if not $featuredImage }}
{{ end }} {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ end }}
{{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ $featuredImage = $featuredImage.Resize "600x" }} {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }}
{{ end }} {{ $featuredImage = $featuredImage.Resize "600x" }}
{{ if .Params.hideFeatureImage }} {{ end }}
{{ $featuredImage = false }} {{ if .Params.hideFeatureImage }}
{{ end }} {{ $featuredImage = false }}
{{ with $featuredImage }} {{ end }}
{{ $className := printf "background-image-%s" (md5 .RelPermalink) }} {{ with $featuredImage }}
<div class="{{ $articleImageClasses }} {{ $className }}"></div> {{ $className := printf "background-image-%s" (md5 .RelPermalink) }}
{{ else }} <div class="{{ $articleImageClasses }} {{ $className }}"></div>
{{ with $.Site.Params.images }} {{ else }}
<meta property="og:image" content="{{ index . 0 | absURL }}" /> {{ with $.Site.Params.images }}
{{ end }} <meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }}
<div class="{{ $articleInnerClasses }}"> <div class="{{ $articleInnerClasses }}">
<div class="items-center text-left text-xl font-semibold"> <div class="items-center text-left text-xl font-semibold">
{{ with .Params.externalUrl }} {{ with .Params.externalUrl }}
<div> <div>
<div <div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
@@ -73,26 +74,29 @@
</span> </span>
</div> </div>
</div> </div>
{{ else }} {{ else }}
<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral" <div
href="{{ .RelPermalink }}">{{ .Title | emojify }}</div> class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
{{ end }} href="{{ .RelPermalink }}">
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ .Title | emojify }}
</div>
{{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
<div class=" ltr:ml-2 rtl:mr-2"> <div class=" ltr:ml-2 rtl:mr-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</div> </div>
{{ end }} {{ end }}
{{ if templates.Exists "partials/extend-article-link.html" }} {{ if templates.Exists "partials/extend-article-link.html" }}
{{ partial "extend-article-link.html" . }} {{ partial "extend-article-link.html" . }}
{{ end }} {{ end }}
</div> </div>
<div class="text-sm text-neutral-500 dark:text-neutral-400"> <div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }} {{ partial "article-meta/basic.html" . }}
</div> </div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 max-w-fit prose dark:prose-invert"> <div class="py-1 max-w-fit prose dark:prose-invert">
{{ .Summary | plainify }} {{ .Summary | plainify }}
</div> </div>
{{ end }} {{ end }}
</div> </div>
</a> </a>