daniel.paste.lol / literal.club-hugo-shortcode · 1 year ago·

<!-- Literal.club widget shortcode for Hugo
     Author: Daniel Santos https://github.com/dldsantos/
-->

<!-- Reset scratch variables at the start 
	 If no values are provided, set default ones
-->
{{ $.Scratch.Set "sc_username" "danielsantos" }}
{{ $.Scratch.Set "sc_layout" "row" }}

{{ if .IsNamedParams }}
	<!-- widget username -->
	{{ with .Get "username" }}
		{{ $.Scratch.Set "sc_username" . }}
	{{ else }}
		{{ $.Scratch.Set "sc_username" "danielsantos" }}
	{{ end }}

	<!-- widget layout - available options: "row" or "list" -->
	{{ with .Get "layout" }}
		{{ $.Scratch.Set "sc_layout" . }}
	{{ else }}
		{{ $.Scratch.Set "sc_layout" "row" }}
	{{ end }}		
{{ else }}
	<!-- widget username -->
	{{ with .Get 0 }}
		{{ $.Scratch.Set "sc_username" . }}
	{{ else }}
		{{ $.Scratch.Set "sc_username" "danielsantos" }}
	{{ end }}

	<!-- widget layout - available options: "row" or "list" -->
	{{ with .Get 1 }}
		{{ $.Scratch.Set "sc_layout" . }}
	{{ else }}
		{{ $.Scratch.Set "sc_layout" "row" }}
	{{ end }}
{{ end }}

<!-- render Literal.club widget -->
<div id="literal-widget" handle="{{ $.Scratch.Get "sc_username" }}" status='IS_READING' layout="{{ $.Scratch.Get "sc_layout" }}"></div>
<script src="https://literal.club/js/widget.js"></script>