Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions layouts/shortcodes/img.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
{{ $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
{{ $customAlt := .Get "alt" }}
{{ $customSize := .Get "size" }}
{{ $lazyLoad := default (default true $.Site.Params.GeekdocImageLazyLoading) (.Get "lazy") }}
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
{{- $customAlt := .Get "alt" }}
{{- $customSize := .Get "size" | lower }}
{{- $lazyLoad := default (default true $.Site.Params.GeekblogImageLazyLoading) (.Get "lazy") }}
Copy link

@wolfspyre wolfspyre Jul 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be Geekdoc?

Copy link

@wolfspyre wolfspyre Jul 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this in general and thought it MIGHT be worth switching all the namespaced vars/attrs/etc to geeklab and only having a select few which are geeklabGB geeklabGD ... might make things easier? or not.... idk really. (I'm rarely convinced my ideas are GOOD...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint! I've created a PR to fix it.


{{ with $source }}
{{ $caption := default .Title $customAlt }}
{{- with $source }}
{{- $caption := default .Title $customAlt }}

{{ $tiny := (.Resize "320x").Permalink }}
{{ $small := (.Resize "600x").Permalink }}
{{ $medium := (.Resize "1200x").Permalink }}
{{ $large := (.Resize "1800x").Permalink }}
{{- $profile := (.Fill "180x180 Center").Permalink }}
{{- $tiny := (.Resize "320x").Permalink }}
{{- $small := (.Resize "600x").Permalink }}
{{- $medium := (.Resize "1200x").Permalink }}
{{- $large := (.Resize "1800x").Permalink }}

{{ $size := dict "tiny" $tiny "small" $small "medium" $medium "large" $large }}
{{- $size := dict "profile" $profile "tiny" $tiny "small" $small "medium" $medium "large" $large }}


<div class="flex justify-center">
<figure class="gdoc-markdown__figure">
<figure
class="gdoc-post__figure
{{- if eq $customSize "profile" }}{{ print " gdoc-post__figure--round" }}{{ end }}"
>
<a class="gdoc-markdown__link--raw" href="{{ .Permalink }}">
<picture>
<source
{{ with $customSize }}
{{- with $customSize }}
srcset="{{ index $size $customSize }}"
{{ else }}
{{- else }}
srcset="{{ $size.small }} 600w, {{ $size.medium }} 1200w" sizes="100vw"
{{ end }}
{{- end }}
/>
<img
{{ if $lazyLoad }}
loading="lazy"
{{ end }}
{{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }}
src="{{ $size.large }}"
alt="{{ $caption }}"
/>
</picture>
</a>
{{ with $caption -}}
<figcaption>
{{ . }}{{ with $source.Params.credits }}({{ . | $.Page.RenderString }}){{ end }}
</figcaption>
{{- if not (eq $customSize "profile") }}
{{- with $caption }}
<figcaption>
{{ . }}
{{- with $source.Params.credits }}
{{ printf " (%s)" . | $.Page.RenderString }}
{{- end }}
</figcaption>
{{- end }}
{{- end }}
</figure>
</div>
{{ end }}
{{- end }}
5 changes: 5 additions & 0 deletions src/sass/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;

&--round,
&--round img {
border-radius: 50% !important;
}

figcaption {
display: table-caption;
caption-side: bottom;
Expand Down