Skip to content

feat: add data-table shortcode for JSON/CSV/YAML-backed tables#465

Open
danielledeleo wants to merge 4 commits intomainfrom
feat/data-table-shortcode
Open

feat: add data-table shortcode for JSON/CSV/YAML-backed tables#465
danielledeleo wants to merge 4 commits intomainfrom
feat/data-table-shortcode

Conversation

@danielledeleo
Copy link
Contributor

@danielledeleo danielledeleo commented Mar 10, 2026

Summary

  • Adds a data-table shortcode that renders JSON, CSV, or YAML data files as static HTML tables at build time
  • Optional client-side column sorting via interactive="true" (vanilla JS, ~130 lines, conditionally loaded)
  • Lucide SVG icons for sort direction indicators (arrow-up-down / arrow-up / arrow-down)

Features

Param Default Description
path (required) Path to data file in assets/
interactive "false" Enable JS column sorting
sort none Default sort: "col" or "col:desc"
columns all Comma-separated column whitelist
hide none Comma-separated column blacklist
labels none Header overrides: "col:Label,col2:Label"
variant "wide" "wide" or "narrow"

Design decisions

  • Build-time rendering -- full <table> always in HTML; JS only enhances with sort. No-JS fallback is free.
  • CSV headers used verbatim -- author controls display names. JSON/YAML keys get humanize | title.
  • Conditional JS loading -- uses the same Page.Store pattern as mermaid; only loaded on pages that use the shortcode.
  • No external dependencies -- vanilla JS, Hugo Pipes only, Lucide icons from existing sprite.

Files changed

  • layouts/shortcodes/data-table.html -- the shortcode
  • assets/js/data-table.js -- sort logic (~130 lines)
  • assets/css/v2/style.css -- data table styles (+80 lines)
  • layouts/partials/scripts.html -- conditional script loading
  • exampleSite/ -- example data files + demo page

Screenshot

Screenshot 2026-03-12 at 2 22 43 PM

@danielledeleo danielledeleo requested a review from a team as a code owner March 10, 2026 21:10
@github-actions

This comment was marked as outdated.

@github-actions
Copy link

Deploy Preview will be available once build job completes!

Name Link
😎 Deploy Preview https://frontdoor-test-docs.nginx.com/previews/nginx-hugo-theme/465/

Render JSON, CSV, or YAML data files as static HTML
tables at build time with optional client-side column
sorting via progressive enhancement.

Support column selection, header label overrides, and
wide/narrow layout variants. Interactive mode adds
vanilla JS sorting with Lucide sort icons. No-JS
fallback is a full static table.
@danielledeleo danielledeleo force-pushed the feat/data-table-shortcode branch from bfc2117 to 77b2fb7 Compare March 10, 2026 21:16
@danielledeleo danielledeleo force-pushed the feat/data-table-shortcode branch from e1a3e50 to ab128dc Compare March 12, 2026 18:20
Support bordered and borderless table styles via a new theme parameter,
matching the existing table shortcode. Default remains bordered.
Document the parameter, add borderless examples, and note the plain-text
cell value limitation.
Add humanize parameter to disable auto-formatting of JSON/YAML keys.
Add markdownify parameter to opt in to markdown processing in cells.
Support \, and \: escape sequences in columns, hide, labels, and sort
parameters. Fix labels parser to preserve colons in label values.

Rewrite documentation for clarity: reorder examples from basic to
advanced, document alphabetical column ordering, add static sort
example, rename edge cases to special characters, strengthen
markdownify security warning, and add edge-case test data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant