From 8d367dfa791b2e2961d0bbbacacc9a3d246c970b Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Wed, 24 Jun 2026 16:10:17 +0200 Subject: [PATCH] Add human file size partial. --- layouts/_partials/human_file_size.html | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 layouts/_partials/human_file_size.html diff --git a/layouts/_partials/human_file_size.html b/layouts/_partials/human_file_size.html new file mode 100644 index 0000000..bf1c0d9 --- /dev/null +++ b/layouts/_partials/human_file_size.html @@ -0,0 +1,7 @@ +{{/* Call this with a resource's content e.g., partial "human_file_size" .Content */}} +{{- $bytes := len . -}} +{{- $kb := div $bytes 1024 -}} +{{- $mb := div $kb 1024 -}} +{{- if ge $mb 1 -}}{{- $mb -}} MB +{{- else if ge $kb 1 -}}{{- $kb -}} KB +{{- else -}}{{- $bytes -}} B{{- end -}}