mirror of
https://github.com/tomfran/typo.git
synced 2025-04-25 13:09:54 +03:00
Add proper table rendering
This commit is contained in:
parent
fda5cc7355
commit
73e65f2014
2 changed files with 49 additions and 0 deletions
|
@ -559,6 +559,11 @@ figcaption {
|
|||
|
||||
/* Tables */
|
||||
|
||||
.table-outer {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin-top: var(--table-margin-top);
|
||||
|
|
44
layouts/_default/_markup/render-table.html
Normal file
44
layouts/_default/_markup/render-table.html
Normal file
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue