mirror of
https://gitee.com/butubb8/blowfish.git
synced 2025-12-05 14:17:50 +08:00
feat: add support for showSummary in article shortcode
This commit is contained in:
@@ -1689,6 +1689,9 @@ body.zen-mode-enable {
|
||||
.p-1\.5 {
|
||||
padding: calc(var(--spacing) * 1.5);
|
||||
}
|
||||
.p-2\.5 {
|
||||
padding: calc(var(--spacing) * 2.5);
|
||||
}
|
||||
.p-4 {
|
||||
padding: calc(var(--spacing) * 4);
|
||||
}
|
||||
@@ -1758,6 +1761,9 @@ body.zen-mode-enable {
|
||||
.py-\[1px\] {
|
||||
padding-block: 1px;
|
||||
}
|
||||
.pt-1 {
|
||||
padding-top: calc(var(--spacing) * 1);
|
||||
}
|
||||
.pt-2 {
|
||||
padding-top: calc(var(--spacing) * 2);
|
||||
}
|
||||
@@ -1785,6 +1791,9 @@ body.zen-mode-enable {
|
||||
.pr-\[24px\] {
|
||||
padding-right: 24px;
|
||||
}
|
||||
.pb-0 {
|
||||
padding-bottom: calc(var(--spacing) * 0);
|
||||
}
|
||||
.pb-2 {
|
||||
padding-bottom: calc(var(--spacing) * 2);
|
||||
}
|
||||
@@ -1809,6 +1818,9 @@ body.zen-mode-enable {
|
||||
.pl-2 {
|
||||
padding-left: calc(var(--spacing) * 2);
|
||||
}
|
||||
.pl-4 {
|
||||
padding-left: calc(var(--spacing) * 4);
|
||||
}
|
||||
.pl-\[24px\] {
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
113
layouts/partials/article-link/_shortcode.html
Normal file
113
layouts/partials/article-link/_shortcode.html
Normal file
@@ -0,0 +1,113 @@
|
||||
{{ $target := .target }}
|
||||
{{ $shortcodeShowSummary := .showSummary }}
|
||||
{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
|
||||
{{ $disableImageOptimization := site.Params.disableImageOptimization | default false }}
|
||||
|
||||
{{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }}
|
||||
{{ if site.Params.list.showCards }}
|
||||
{{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }}
|
||||
{{ else }}
|
||||
{{ $articleClasses = delimit (slice $articleClasses "") " " }}
|
||||
{{ end }}
|
||||
|
||||
{{ $articleImageClasses := "w-full md:w-auto h-full thumbnail nozoom" }}
|
||||
{{ if site.Params.list.showCards }}
|
||||
{{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }}
|
||||
{{ else }}
|
||||
{{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }}
|
||||
{{ end }}
|
||||
|
||||
{{ $articleInnerClasses := "" }}
|
||||
{{ if site.Params.list.showCards }}
|
||||
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-2.5 pl-4 pb-0") " " }}
|
||||
{{ else }}
|
||||
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $constrainItemsWidth }}
|
||||
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<a class="{{ $articleClasses }}" {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}>
|
||||
{{- with $target.Params.images -}}
|
||||
{{- range first 6 . }}
|
||||
<meta property="og:image" content="{{ . | absURL }}">
|
||||
{{ end -}}
|
||||
{{- else -}}
|
||||
{{- $images := $target.Resources.ByType "image" -}}
|
||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{ if and $target.Params.featureimage (not $featured) }}
|
||||
{{- $url:= $target.Params.featureimage -}}
|
||||
{{ $featured = resources.GetRemote $url }}
|
||||
{{ end }}
|
||||
{{- if not $featured }}
|
||||
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
|
||||
{{ end -}}
|
||||
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
|
||||
{{- with $featured -}}
|
||||
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
|
||||
{{ with . }}
|
||||
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ with .Resize "600x" }}
|
||||
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- else -}}
|
||||
{{- with site.Params.images }}
|
||||
<meta property="og:image" content="{{ index . 0 | absURL }}">
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
<div class="{{ $articleInnerClasses }}">
|
||||
<div class="items-center text-left text-xl font-semibold">
|
||||
{{ with $target.Params.externalUrl }}
|
||||
<div>
|
||||
<div
|
||||
class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
|
||||
{{ $target.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
<span class="ltr:hidden">↖</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div
|
||||
class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2"
|
||||
href="{{ $target.RelPermalink }}">
|
||||
{{ $target.Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if and $target.Draft site.Params.article.showDraftLabel }}
|
||||
<div class="ltr:ml-2 rtl:mr-2">
|
||||
{{ partial "badge.html" (i18n "article.draft" | emojify) }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if templates.Exists "partials/extend-article-link.html" }}
|
||||
{{ partial "extend-article-link.html" $target }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="text-sm text-neutral-500 dark:text-neutral-400">
|
||||
{{ partial "article-meta/basic.html" $target }}
|
||||
</div>
|
||||
{{ $showSummary := false }}
|
||||
{{ if ne $shortcodeShowSummary nil }}
|
||||
{{ $showSummary = $shortcodeShowSummary }}
|
||||
{{ else }}
|
||||
{{ $showSummary = $target.Params.showSummary | default (site.Params.list.showSummary | default false) }}
|
||||
{{ end }}
|
||||
{{ if $showSummary }}
|
||||
<div class="overflow-hidden pt-1">
|
||||
<div class="prose dark:prose-invert max-w-fit">
|
||||
{{ $target.Summary | plainify }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</a>
|
||||
@@ -1,10 +1,12 @@
|
||||
{{ $link := .Get "link" }}
|
||||
{{ $showSummary := .Get "showSummary" }}
|
||||
{{ $target := .Page }}
|
||||
{{ if ne $link .Page.RelPermalink }}
|
||||
{{ $target = index (first 1 (where .Site.AllPages "RelPermalink" $link)) 0 }}
|
||||
{{ end }}
|
||||
{{ if $target }}
|
||||
<section class="space-y-10 w-full">
|
||||
{{ partial "article-link/simple.html" $target }}
|
||||
{{ $context := dict "target" $target "showSummary" $showSummary }}
|
||||
{{ partial "article-link/_shortcode.html" $context }}
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user