summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Tomaselli <tomaselli.fr@gmail.com>2025-04-18 11:17:00 +0200
committerGitHub <noreply@github.com>2025-04-18 11:17:00 +0200
commitf3877a494e3b6196ac8061c676880046a93bfe9a (patch)
tree2cc6c24550f4f593f3e8ad2bd3c0531ffe1fdf70
parent52e58abda7e2af16e47dd4fb089eac41c1220ea8 (diff)
parent853fbc5cfbf07c292646fc561560cbb6d434a0df (diff)
Merge pull request #120 from tomfran/feature/tables_render
Add proper table rendering
-rw-r--r--assets/css/main.css5
-rw-r--r--layouts/_default/_markup/render-table.html44
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