From 62aa99f85bc98ca97ca4f798dfc8b0d507c0fb4b Mon Sep 17 00:00:00 2001
From: Kamisama <166204452+NITHINSPACETIME@users.noreply.github.com>
Date: Sun, 18 Jan 2026 04:54:49 +0000
Subject: [PATCH] feat: add dynamic identifiers to body and article classes per page (#887)
---
layouts/baseof.html | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/layouts/baseof.html b/layouts/baseof.html
index 1c2968f..ba1d1a6 100644
--- a/layouts/baseof.html
+++ b/layouts/baseof.html
@@ -56,9 +56,22 @@
{{ block "head" . }}{{ partials.Include "head-additions.html" . }}{{ end }}
</head>
- {{- $environment := hugo.Environment | compare.Default "production" -}}
- <body class="ma0 {{ $.Param "body_classes" | compare.Default "avenir bg-near-white"}} {{ $environment }}">
+ {{- $environment := hugo.Environment | default "production" -}}
+ {{/* Generate dynamic classes for the body tag */}}
+ {{- $body_classes := slice "ma0" ($.Param "body_classes" | default "avenir bg-near-white") $environment -}}
+ {{- $body_classes = $body_classes | append (printf "is-%s" .Kind) -}}
+
+ {{- if .IsPage -}}
+ {{- $body_classes = $body_classes | append "is-page" -}}
+ {{- with .File -}}
+ {{- $body_classes = $body_classes | append (printf "page-%s" .ContentBaseName) -}}
+ {{- end -}}
+ {{- end -}}
+
+ {{- if .IsSection -}}{{- $body_classes = $body_classes | append "is-section" -}}{{- end -}}
+
+ <body class="{{ delimit $body_classes " " }}">
{{ block "header" . }}{{ partials.Include "site-header.html" .}}{{ end }}
<main class="pb7" role="main">
{{ block "main" . }}{{ end }}
--
Gitblit v1.10.0