diff options
author | Indrajith K L | 2022-03-19 16:54:23 +0530 |
---|---|---|
committer | Indrajith K L | 2022-03-19 16:54:23 +0530 |
commit | 29fcd231e3da9b33c237886f3c1bb30a557ad641 (patch) | |
tree | 8eba56550b35938e7c445c9ed6d9005c14036666 /themes/PaperMod/layouts/shortcodes | |
download | experimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.tar.gz experimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.tar.bz2 experimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.zip |
Initial Commit
Diffstat (limited to 'themes/PaperMod/layouts/shortcodes')
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/blockquote.html | 72 | ||||
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/collapse.html | 8 | ||||
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/figure.html | 31 | ||||
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/ltr.html | 15 | ||||
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/rawhtml.html | 2 | ||||
-rw-r--r-- | themes/PaperMod/layouts/shortcodes/rtl.html | 15 |
6 files changed, 143 insertions, 0 deletions
diff --git a/themes/PaperMod/layouts/shortcodes/blockquote.html b/themes/PaperMod/layouts/shortcodes/blockquote.html new file mode 100644 index 0000000..14bb107 --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/blockquote.html @@ -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> diff --git a/themes/PaperMod/layouts/shortcodes/collapse.html b/themes/PaperMod/layouts/shortcodes/collapse.html new file mode 100644 index 0000000..17d8d3b --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/collapse.html @@ -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> diff --git a/themes/PaperMod/layouts/shortcodes/figure.html b/themes/PaperMod/layouts/shortcodes/figure.html new file mode 100644 index 0000000..8c93eff --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/figure.html @@ -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> diff --git a/themes/PaperMod/layouts/shortcodes/ltr.html b/themes/PaperMod/layouts/shortcodes/ltr.html new file mode 100644 index 0000000..4ad7682 --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/ltr.html @@ -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> diff --git a/themes/PaperMod/layouts/shortcodes/rawhtml.html b/themes/PaperMod/layouts/shortcodes/rawhtml.html new file mode 100644 index 0000000..520ec17 --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/rawhtml.html @@ -0,0 +1,2 @@ +<!-- raw html --> +{{.Inner}}
\ No newline at end of file diff --git a/themes/PaperMod/layouts/shortcodes/rtl.html b/themes/PaperMod/layouts/shortcodes/rtl.html new file mode 100644 index 0000000..a69b8ce --- /dev/null +++ b/themes/PaperMod/layouts/shortcodes/rtl.html @@ -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> |