diff --git a/.prettierignore b/.prettierignore index e12b83d00..39d080729 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,7 @@ **/icons.html # These are whitespace sensitive. layouts/_default/_markup/render-code* +layouts/_default/_markup/render-table* # Odd template syntax. layouts/_default/_markup/render-heading* @@ -12,4 +13,3 @@ layouts/partials/layouts/head/head.html # Auto generated. assets/css/components/chroma*.css assets/jsconfig.json - diff --git a/assets/css/components/content.css b/assets/css/components/content.css index 607548dbd..ef9b8bbd3 100644 --- a/assets/css/components/content.css +++ b/assets/css/components/content.css @@ -30,7 +30,7 @@ @apply prose-code:px-0.5 prose-code:text-gray-500 prose-code:dark:text-gray-300 border-none; @apply prose-code:before:hidden prose-code:after:hidden prose-code:font-mono; /* tables */ - @apply prose-table:border-2 prose-table:border-gray-100 prose-table:dark:border-gray-800 prose-table:relative prose-table:overflow-scroll prose-table:prose-th:font-bold prose-table:prose-th:bg-blue-500 dark:prose-table:prose-th:bg-blue-500/50 prose-table:prose-th:p-2 prose-table:prose-td:p-2 prose-table:prose-th:text-white; + @apply prose-table:w-auto prose-table:border-2 prose-table:border-gray-100 prose-table:dark:border-gray-800 prose-table:prose-th:font-bold prose-table:prose-th:bg-blue-500 dark:prose-table:prose-th:bg-blue-500/50 prose-table:prose-th:p-2 prose-table:prose-td:p-2 prose-table:prose-th:text-white; /* hr */ @apply dark:prose-hr:border-slate-800; diff --git a/layouts/_default/_markup/render-table.html b/layouts/_default/_markup/render-table.html new file mode 100644 index 000000000..7f3a88601 --- /dev/null +++ b/layouts/_default/_markup/render-table.html @@ -0,0 +1,31 @@ +
+ + + {{- range .THead }} + + {{- range . }} + + {{- end }} + + {{- end }} + + + {{- range .TBody }} + + {{- range . }} + + {{- end }} + + {{- end }} + +
+ {{- .Text -}} +
+ {{- .Text -}} +
+
diff --git a/layouts/shortcodes/datatable-filtered.html b/layouts/shortcodes/datatable-filtered.html index 36db0397a..de8b0cf55 100644 --- a/layouts/shortcodes/datatable-filtered.html +++ b/layouts/shortcodes/datatable-filtered.html @@ -10,32 +10,38 @@ {{ $list := where $list $filter1 $filter2 $filter3 }} - - - {{ range $fields }} - - {{ end }} - - {{ range $list }} - - {{ range $k, $v := . }} - {{ $.Scratch.Set $k $v }} - {{ end }} - {{ range $k, $v := $fields }} - +
{{ . }}
- {{ $tdContent := $.Scratch.Get . }} - {{ if eq $k 3 }} - {{ printf "%v" $tdContent | - strings.ReplaceRE `\[` "
  1. " | - strings.ReplaceRE `\s` "
  2. " | - strings.ReplaceRE `\]` "
" | - safeHTML - }} - {{ else }} - {{ $tdContent }} +
+ + + + {{ range $fields }} + + {{ end }} + + + + {{ range $list }} + + {{ range $k, $v := . }} + {{ $.Scratch.Set $k $v }} {{ end }} - + {{ range $k, $v := $fields }} + + {{ end }} + {{ end }} - - {{ end }} -
{{ . }}
+ {{ $tdContent := $.Scratch.Get . }} + {{ if eq $k 3 }} + {{ printf "%v" $tdContent | + strings.ReplaceRE `\[` "
  1. " | + strings.ReplaceRE `\s` "
  2. " | + strings.ReplaceRE `\]` "
" | + safeHTML + }} + {{ else }} + {{ $tdContent }} + {{ end }} +
+
+ diff --git a/layouts/shortcodes/datatable.html b/layouts/shortcodes/datatable.html index 12054f89d..b06f47ee9 100644 --- a/layouts/shortcodes/datatable.html +++ b/layouts/shortcodes/datatable.html @@ -4,30 +4,36 @@ {{ $fields := after 2 .Params }} - - - {{ range $fields }} - {{ $s := . }} - {{ if eq $s "_key" }} - {{ $s = "Type" }} - {{ end }} - - {{ end }} - - {{ range $k1, $v1 := $list }} - - {{ range $k2, $v2 := . }} - {{ $.Scratch.Set $k2 $v2 }} - {{ end }} - {{ range $fields }} - {{ $s := "" }} - {{ if eq . "_key" }} - {{ $s = $k1 }} - {{ else }} - {{ $s = $.Scratch.Get . }} +
+
{{ $s }}
+ + + {{ range $fields }} + {{ $s := . }} + {{ if eq $s "_key" }} + {{ $s = "Type" }} + {{ end }} + {{ end }} - + + + + {{ range $k1, $v1 := $list }} + + {{ range $k2, $v2 := . }} + {{ $.Scratch.Set $k2 $v2 }} + {{ end }} + {{ range $fields }} + {{ $s := "" }} + {{ if eq . "_key" }} + {{ $s = $k1 }} + {{ else }} + {{ $s = $.Scratch.Get . }} + {{ end }} + + {{ end }} + {{ end }} - - {{ end }} -
{{ $s }}{{ $s }}
{{ $s }}
+ + +