This commit is contained in:
parent
2b840e017b
commit
138071bfb8
106 changed files with 4673 additions and 0 deletions
72
themes/PaperMod/layouts/shortcodes/blockquote.html
Normal file
72
themes/PaperMod/layouts/shortcodes/blockquote.html
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
<!-- Author: Parsia Hakimian https://github.com/parsiya/Hugo-Shortcodes -->
|
||||
<!-- port of Octopress blockquote plugin http://octopress.org/docs/plugins/blockquote/ to Hugo
|
||||
see readme for usage -->
|
||||
|
||||
<!-- reset scratch variables at the start -->
|
||||
{{ $.Scratch.Set "bl_author" false }}
|
||||
{{ $.Scratch.Set "bl_source" false }}
|
||||
{{ $.Scratch.Set "bl_link" false }}
|
||||
{{ $.Scratch.Set "bl_title" false }}
|
||||
|
||||
{{ if .IsNamedParams }}
|
||||
{{ $.Scratch.Set "bl_author" (.Get "author") }}
|
||||
{{ $.Scratch.Set "bl_source" (.Get "source") }}
|
||||
{{ $.Scratch.Set "bl_link" (.Get "link") }}
|
||||
{{ $.Scratch.Set "bl_title" (.Get "title") }}
|
||||
{{ else }}
|
||||
<!-- for the positional version if any -->
|
||||
{{ end }}
|
||||
|
||||
<!-- if title is not set explicitly then we need to beautify the link
|
||||
if length of link is more than 32 chars, we will cut it off by 32 and
|
||||
then drop everything after the last / if any and put it in into title -->
|
||||
|
||||
{{ with $.Scratch.Get "bl_title" }}
|
||||
<!-- do nothing -->
|
||||
{{ else }}
|
||||
{{ with $.Scratch.Get "bl_link" }} <!-- if link is given -->
|
||||
{{ range last 1 (split ($.Scratch.Get "bl_link" ) "://") }} <!-- split by :// and then only take the items after it to remove protocol:// -->
|
||||
{{ $.Scratch.Set "title_without_protocol" . }}
|
||||
{{ end }}
|
||||
{{ range last 1 (split ($.Scratch.Get "title_without_protocol" ) "www.") }} <!-- also remove the www. at the start if any. we are using a second split because all URLS may not start with it -->
|
||||
{{ $.Scratch.Set "title_without_protocol" . }}
|
||||
{{ end }}
|
||||
{{ $.Scratch.Set "bl_title" ($.Scratch.Get "title_without_protocol") }}
|
||||
|
||||
<!-- if link is longer than 32 bytes we should trim it -->
|
||||
{{ if (gt (len ($.Scratch.Get "title_without_protocol") ) 32) }}
|
||||
{{ $title := (slicestr ($.Scratch.Get "title_without_protocol") 0 32) }} <!-- get the first 32 characters of title_without_protocol -->
|
||||
{{ $split_by_fw_slash := split $title "/" }} <!-- now split on / because we want to stop after the last forward slash -->
|
||||
{{ $count := (sub (len $split_by_fw_slash) 1) }} <!-- we want everything but the last part so we adjust the count accordingly -->
|
||||
|
||||
{{ $.Scratch.Set "tempstring" "" }} <!-- temp variable to hold the concatinated string -->
|
||||
{{ range first $count $split_by_fw_slash }} <!-- loop through all parts except last and concat them (add / between halves) -->
|
||||
{{ $.Scratch.Set "tempstring" ( . | printf "%s%s/" ($.Scratch.Get "tempstring") | printf "%s" ) }}
|
||||
{{ end }}
|
||||
{{ $.Scratch.Set "bl_title" ( printf "%s..." ($.Scratch.Get "tempstring") | printf "%s" ) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<blockquote>
|
||||
<p>{{ .Inner | markdownify }}</p>
|
||||
<footer>
|
||||
<strong>{{ with $.Scratch.Get "bl_author" }}{{ . }}{{ end }}</strong>
|
||||
{{ with $.Scratch.Get "bl_source" }}
|
||||
<cite>{{ . }}</cite>
|
||||
{{ else }}
|
||||
{{ with $.Scratch.Get "bl_link" }}
|
||||
<cite>
|
||||
<a href="{{ . }}" title="{{ . }}">{{ $.Scratch.Get "bl_title" }}</a> <!-- can't have new lines here -->
|
||||
</cite>
|
||||
{{ else }}
|
||||
{{ with $.Scratch.Get "bl_title" }}
|
||||
<cite>
|
||||
{{ $.Scratch.Get "bl_title" }}</a>
|
||||
</cite>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</footer>
|
||||
</blockquote>
|
||||
8
themes/PaperMod/layouts/shortcodes/collapse.html
Normal file
8
themes/PaperMod/layouts/shortcodes/collapse.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{{ if .Get "summary" }}
|
||||
{{ else }}
|
||||
{{ warnf "missing value for param 'summary': %s" .Position }}
|
||||
{{ end }}
|
||||
<p><details {{ if (eq (.Get "openByDefault") true) }} open=true {{ end }}>
|
||||
<summary markdown="span">{{ .Get "summary" | markdownify }}</summary>
|
||||
{{ .Inner | markdownify }}
|
||||
</details></p>
|
||||
31
themes/PaperMod/layouts/shortcodes/figure.html
Normal file
31
themes/PaperMod/layouts/shortcodes/figure.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<figure{{ if or (.Get "class") (eq (.Get "align") "center") }} class="
|
||||
{{- if eq (.Get "align") "center" }}align-center {{ end }}
|
||||
{{- with .Get "class" }}{{ . }}{{- end }}"
|
||||
{{- end -}}>
|
||||
{{- if .Get "link" -}}
|
||||
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
||||
{{- end }}
|
||||
<img loading="lazy" src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
|
||||
{{- if or (.Get "alt") (.Get "caption") }}
|
||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
||||
{{- end -}}
|
||||
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
|
||||
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
|
||||
/> <!-- Closing img tag -->
|
||||
{{- if .Get "link" }}</a>{{ end -}}
|
||||
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
|
||||
<figcaption>
|
||||
{{ with (.Get "title") -}}
|
||||
{{ . }}
|
||||
{{- end -}}
|
||||
{{- if or (.Get "caption") (.Get "attr") -}}<p>
|
||||
{{- .Get "caption" | markdownify -}}
|
||||
{{- with .Get "attrlink" }}
|
||||
<a href="{{ . }}">
|
||||
{{- end -}}
|
||||
{{- .Get "attr" | markdownify -}}
|
||||
{{- if .Get "attrlink" }}</a>{{ end }}</p>
|
||||
{{- end }}
|
||||
</figcaption>
|
||||
{{- end }}
|
||||
</figure>
|
||||
15
themes/PaperMod/layouts/shortcodes/ltr.html
Normal file
15
themes/PaperMod/layouts/shortcodes/ltr.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{{ $.Scratch.Set "md" false }}
|
||||
|
||||
{{ if .IsNamedParams }}
|
||||
{{ $.Scratch.Set "md" (.Get "md") }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "md" (.Get 0) }}
|
||||
{{ end }}
|
||||
|
||||
<div dir="ltr">
|
||||
{{ if eq ($.Scratch.Get "md") false }}
|
||||
{{ .Inner }}
|
||||
{{ else }}
|
||||
{{ .Inner | markdownify }}
|
||||
{{ end }}
|
||||
</div>
|
||||
2
themes/PaperMod/layouts/shortcodes/rawhtml.html
Normal file
2
themes/PaperMod/layouts/shortcodes/rawhtml.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!-- raw html -->
|
||||
{{.Inner}}
|
||||
15
themes/PaperMod/layouts/shortcodes/rtl.html
Normal file
15
themes/PaperMod/layouts/shortcodes/rtl.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{{ $.Scratch.Set "md" false }}
|
||||
|
||||
{{ if .IsNamedParams }}
|
||||
{{ $.Scratch.Set "md" (.Get "md") }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "md" (.Get 0) }}
|
||||
{{ end }}
|
||||
|
||||
<div dir="rtl">
|
||||
{{ if eq ($.Scratch.Get "md") false }}
|
||||
{{ .Inner }}
|
||||
{{ else }}
|
||||
{{ .Inner | markdownify }}
|
||||
{{ end }}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue