mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
146 lines
5.3 KiB
HTML
146 lines
5.3 KiB
HTML
{{/* Used by
|
|
1. article shortcode
|
|
|
|
The four variants of article-link are very similar. Despite appearances, as of df859f:
|
|
- _shortcode.html uses $page := $target, while the others use $page := .Page
|
|
- card-related.html does not have the hideFeatureImage option, while the others do
|
|
|
|
$page is added intentionally to prevent small differences inside
|
|
*/}}
|
|
{{ $target := .target }}
|
|
{{ $shortcodeShowSummary := .showSummary }}
|
|
{{ $shortcodeCompactSummary := .compactSummary }}
|
|
{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
|
|
{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }}
|
|
|
|
{{ $cardClasses := "flex flex-col md:flex-row relative" }}
|
|
{{ $figureClasses := "" }}
|
|
{{ $cardContentClasses := "" }}
|
|
|
|
{{ if site.Params.list.showCards }}
|
|
{{ $cardClasses = printf "%s overflow-hidden rounded-md border-2 border-neutral-200 dark:border-neutral-700" $cardClasses }}
|
|
{{ $figureClasses = "" }}
|
|
{{ $cardContentClasses = printf "%s p-4 pt-2" $cardContentClasses }}
|
|
{{ else }}
|
|
{{ $cardClasses = printf "%s" $cardClasses }}
|
|
{{ $figureClasses = printf "%s thumbnail-shadow md:mr-7" $figureClasses }}
|
|
{{ $cardContentClasses = printf "%s mt-3 md:mt-0" $cardContentClasses }}
|
|
{{ end }}
|
|
|
|
{{ if $constrainItemsWidth }}
|
|
{{ $cardClasses = printf "%s max-w-prose" $cardClasses }}
|
|
{{ end }}
|
|
|
|
{{ $page := $target }}
|
|
{{ $featured := "" }}
|
|
{{ $featuredURL := "" }}
|
|
{{ if not $target.Params.hideFeatureImage }}
|
|
{{/* frontmatter */}}
|
|
{{ with $page }}
|
|
{{ with .Params.featureimage }}
|
|
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
|
|
{{ if site.Params.hotlinkFeatureImage }}
|
|
{{ $featuredURL = . }}
|
|
{{ else }}
|
|
{{ $featured = resources.GetRemote . }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ $featured = resources.Get . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{/* page resources */}}
|
|
{{ if not (or $featured $featuredURL) }}
|
|
{{ $images := .Resources.ByType "image" }}
|
|
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
|
|
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{/* fallback to default */}}
|
|
{{ if not (or $featured $featuredURL) }}
|
|
{{ $default := site.Store.Get "defaultFeaturedImage" }}
|
|
{{ if $default.url }}
|
|
{{ $featuredURL = $default.url }}
|
|
{{ else if $default.obj }}
|
|
{{ $featured = $default.obj }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{/* generate image URL if not hotlink */}}
|
|
{{ if not $featuredURL }}
|
|
{{ with $featured }}
|
|
{{ $featuredURL = .RelPermalink }}
|
|
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
|
{{ $featuredURL = (.Resize "600x").RelPermalink }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
|
|
<article class="{{ $cardClasses }}">
|
|
{{ with $featuredURL }}
|
|
<figure class="not-prose flex-none relative overflow-hidden {{ $figureClasses }} thumbnail--simple">
|
|
<img
|
|
src="{{ . }}"
|
|
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">
|
|
</figure>
|
|
{{ end }}
|
|
<div class="{{ $cardContentClasses }}">
|
|
<header class="items-center text-start text-xl font-semibold">
|
|
<a
|
|
{{ with .Params.externalUrl }}
|
|
href="{{ . }}" target="_blank" rel="external"
|
|
{{ else }}
|
|
href="{{ .RelPermalink }}"
|
|
{{ end }}
|
|
class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
|
|
<h2>
|
|
{{ $target.Title | emojify }}
|
|
{{ if $target.Params.externalUrl }}
|
|
<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>
|
|
{{ end }}
|
|
</h2>
|
|
</a>
|
|
{{ if and $target.Draft site.Params.article.showDraftLabel }}
|
|
<div class="ms-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 }}
|
|
</header>
|
|
<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 }}
|
|
{{ $compactSummary := false }}
|
|
{{ if ne $shortcodeCompactSummary nil }}
|
|
{{ $compactSummary = $shortcodeCompactSummary }}
|
|
{{ else }}
|
|
{{ $compactSummary = $target.Params.compactSummary | default (site.Params.list.compactSummary | default false) }}
|
|
{{ end }}
|
|
<div class="overflow-hidden pt-1">
|
|
<div class="{{ if $compactSummary }}line-clamp-3{{ end }} prose dark:prose-invert max-w-fit">
|
|
{{ $target.Summary | plainify }}
|
|
</div>
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
</article>
|