diff options
author | Francesco <tomaselli.fr@gmail.com> | 2025-04-18 11:15:18 +0200 |
---|---|---|
committer | Francesco <tomaselli.fr@gmail.com> | 2025-04-18 11:15:18 +0200 |
commit | 853fbc5cfbf07c292646fc561560cbb6d434a0df (patch) | |
tree | 2cc6c24550f4f593f3e8ad2bd3c0531ffe1fdf70 | |
parent | 52e58abda7e2af16e47dd4fb089eac41c1220ea8 (diff) |
Add proper table rendering
-rw-r--r-- | assets/css/main.css | 5 | ||||
-rw-r--r-- | layouts/_default/_markup/render-table.html | 44 |
2 files changed, 49 insertions, 0 deletions
diff --git a/assets/css/main.css b/assets/css/main.css index b2a95af..7ae1fce 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -559,6 +559,11 @@ figcaption { /* Tables */ +.table-outer { + width: 100%; + overflow-x: auto; +} + table { border-collapse: collapse; margin-top: var(--table-margin-top); diff --git a/layouts/_default/_markup/render-table.html b/layouts/_default/_markup/render-table.html new file mode 100644 index 0000000..5534d3a --- /dev/null +++ b/layouts/_default/_markup/render-table.html @@ -0,0 +1,44 @@ +{{/* +Default table rendered plus an outer div to align and overflow tables +accordingly. +Ref: https://gohugo.io/render-hooks/tables/ +*/}} +<div class="table-outer"> + <table + {{- range $k, $v :=.Attributes }} + {{- if $v }} + {{- printf " %s=%q" $k $v | safeHTMLAttr }} + {{- end }} + {{- end }}> + <thead> + {{- range .THead }} + <tr> + {{- range . }} + <th + {{- with .Alignment }} + {{- printf " style=%q" (printf "text-align: %s" .) | + safeHTMLAttr }} + {{- end -}}> + {{- .Text -}} + </th> + {{- end }} + </tr> + {{- end }} + </thead> + <tbody> + {{- range .TBody }} + <tr> + {{- range . }} + <td + {{- with .Alignment }} + {{- printf " style=%q" (printf "text-align: %s" .) | + safeHTMLAttr }} + {{- end -}}> + {{- .Text -}} + </td> + {{- end }} + </tr> + {{- end }} + </tbody> + </table> +</div>
\ No newline at end of file |