1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 21:02:09 +00:00
seirdy.one/layouts/shortcodes/figcaption.html
Rohan Kumar 84cde2e97f
Internal: create + use figure shortcodes + hooks
Create a for <figcaption> and a render hook for code snippets inside
figures, replacing some ugly and complex inline HTML in my markdown
sources.

The only visible change is slightly worse HTML alignment and programming
language indicators (with microdata).

This removed the need to use one of the regex replacements in the
processed_content.html shortcode, and increased the minimum required
Hugo version to 0.93.
2022-04-18 21:15:29 -07:00

22 lines
603 B
HTML

<figcaption>
{{ if .Get "type" | eq "code" }}
<strong itemprop="codeSampleType">Code snippet</strong>{{with .Get "lang"}} (<span itemprop="programmingLanguage">{{ . }}</span>){{end}}:
{{- end }}
{{ $contents := (.Inner | markdownify | safeHTML) }}
{{ if .Get "type" | eq "citation" }}
&mdash;
<span class="h-cite" itemprop="citation" role="doc-credit">
{{with .Get "partOfType" }}
<span itemprop="isPartOf" itemscope itemtype="https://schema.org/{{ . }}">
{{ end }}
{{ $contents }}
{{with .Get "partOfType" }}
</span>
{{ end }}
</span>
{{ else }}
{{ $contents }}
{{- end }}
</figcaption>