{{- /* Timeline support for code fences extended and shortcodes. */ -}} {{- $reverse := .Options.reverse | default false -}} {{- $placement := .Options.placement | default "bottom" -}} {{- $animation := .Options.animation | default false -}} {{- $size := .Options.size | default "medium" -}} {{- $node := .Options.node | default "circle" -}} {{- $data := .Options.data -}} {{- $file := .Options.file -}} {{- /* Get Timeline events */ -}} {{- $content := .Inner -}} {{ with $data }} {{- $content = index hugo.Data.timeline (printf "%v.%v" . page.Language) | default (index hugo.Data.timeline .) -}} {{- if not $content -}} {{- warnf "Timeline: data not found, please ensure the data file \"data/timeline/%s.{json|yml|yaml|toml}\" exists." . -}} {{- end -}} {{- else -}} {{- with dict "Path" $file "Resources" .Resources | partial "function/resource.html" }} {{- $content = .Content -}} {{- else with $file -}} {{- warnf "Timeline: no such data file: %s" . -}} {{- end -}} {{- $content = $content | transform.Unmarshal -}} {{- end -}} {{- $events := $content.events | default slice -}} {{- with .Events -}} {{- $events = . -}} {{- end -}} {{- $events = sort $events "timestamp" (cond $reverse "desc" "asc") -}} {{- if not $events -}} {{- warnf "Timeline: events is empty, executing in file %s" $.Position -}} {{- end -}} {{- /* Set Timeline style */ -}} {{- $style := "" -}} {{- with .Options.width -}} {{- $style = printf "width: %v;" . -}} {{- end -}} {{- with .Options.height -}} {{- $style = add $style (printf "height: %v;" .) -}} {{- end -}} {{- with $style -}} {{- $style = printf `style="%v"` . -}} {{- end -}}