From 949d73c141f56cae79f6688c9faba4294251a0ff Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sun, 3 May 2026 12:19:16 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20layout=20variants=20=E2=80=94=20params.?= =?UTF-8?q?layout=20=3D=20stack/grid/inline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Validate against allowlist in bio-card.html, warnf + fall back to stack on unknown values. - Variant CSS scoped under .bio__links--{variant} to avoid v0.2-style specificity collisions. - Inline variant visually-hides .link__title via clip-path; titles stay in DOM for screen readers. - Grid collapses to 1-col under 480px. - New /variants/ gallery page renders all three side by side. - exampleSite switches to layout = "grid" so the live demo shows the new feature. --- .../exampleSite/content/variants/index.md | 4 + themes/bonsai/exampleSite/hugo.toml | 2 + themes/bonsai/layouts/partials/bio-card.html | 8 +- themes/bonsai/layouts/variants/single.html | 36 +++++++++ themes/bonsai/static/css/bonsai.css | 74 +++++++++++++++++++ 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 themes/bonsai/exampleSite/content/variants/index.md create mode 100644 themes/bonsai/layouts/variants/single.html diff --git a/themes/bonsai/exampleSite/content/variants/index.md b/themes/bonsai/exampleSite/content/variants/index.md new file mode 100644 index 0000000..9e02533 --- /dev/null +++ b/themes/bonsai/exampleSite/content/variants/index.md @@ -0,0 +1,4 @@ +--- +title: "Layout variants" +type: variants +--- diff --git a/themes/bonsai/exampleSite/hugo.toml b/themes/bonsai/exampleSite/hugo.toml index 76aacef..55f25cb 100644 --- a/themes/bonsai/exampleSite/hugo.toml +++ b/themes/bonsai/exampleSite/hugo.toml @@ -13,9 +13,11 @@ disableKinds = ["taxonomy", "term", "RSS", "sitemap", "404"] # avatar omitted intentionally so the demo showcases the initials fallback # (the SVG circle uses the active palette's accent color) colorTheme = "sakura" # try "bonsai" (default), "sakura", "sumi", "koi" + layout = "grid" # try "stack" (default), "grid", "inline" themeToggle = true jobTitle = "Software Engineer" footerText = "© 2026 · made with bonsai" + # ogImageUrl = "/og.png" # optional 1200×630 image for social previews [[params.links]] title = "GitHub" diff --git a/themes/bonsai/layouts/partials/bio-card.html b/themes/bonsai/layouts/partials/bio-card.html index 7e7304f..732afa2 100644 --- a/themes/bonsai/layouts/partials/bio-card.html +++ b/themes/bonsai/layouts/partials/bio-card.html @@ -2,6 +2,12 @@ {{- $tagline := site.Params.tagline -}} {{- $bio := site.Params.bio -}} {{- $links := site.Params.links -}} +{{- $layout := site.Params.layout | default "stack" -}} +{{- $validLayouts := slice "stack" "grid" "inline" -}} +{{- if not (in $validLayouts $layout) -}} + {{- warnf "bonsai: unknown params.layout %q (expected stack|grid|inline), falling back to 'stack'" $layout -}} + {{- $layout = "stack" -}} +{{- end -}}
{{ partial "avatar.html" . }} @@ -17,7 +23,7 @@ {{- end }} {{- if $links }} -