From b3eed6a99211348bcd3c4a13edbcdeedd77cf119 Mon Sep 17 00:00:00 2001 From: Marcus Blom <158522975+marblom007@users.noreply.github.com> Date: Wed, 15 Jul 2026 15:52:31 +0000 Subject: [PATCH] Respect build draft mode in content ID validation Draft modules are now only validated when the build actually renders them (hugo --buildDrafts). When draft mode is off, draft content is skipped entirely instead of being run through registry validation, so it is neither checked nor reported as a warning. Draft state is derived from Hugo's build-aware page status; the file-based draft fallback now marks such content with a neutral draft status and skips validation rather than emitting a draft warning. Drafts that are being built keep the existing soft draft_warning behaviour and never block publishing. Signed-off-by: Marcus Blom <158522975+marblom007@users.noreply.github.com> --- README.md | 11 ++++++++--- .../collect-content-health.html | 17 ++++++++++++++--- layouts/shortcodes/instructor-toolkit.html | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c370160..3e85800 100644 --- a/README.md +++ b/README.md @@ -173,9 +173,14 @@ Supported `validationMode` values: - `off` suppresses content health warnings and skips registry lookups. Registry lookups are scoped to root learning paths, challenges, and -certifications. Draft root content is not warning-producing and is hidden from -the Instructor Toolkit report. Nested course/module/page/test IDs are not -checked against the Cloud curriculum registry. +certifications. Nested course/module/page/test IDs are not checked against the +Cloud curriculum registry. + +Validation respects the build's draft mode. Draft content is only validated +when the build actually renders it (`hugo --buildDrafts`); those drafts are +checked softly and never block publishing. When draft mode is off, draft +modules are not part of the build and are skipped entirely — they are neither +checked against the registry nor reported as warnings. If `params.academy.registryURL` is not configured, the build prints one configuration warning and does not report existing IDs as invalid because they diff --git a/layouts/partials/academy-validation/collect-content-health.html b/layouts/partials/academy-validation/collect-content-health.html index 31d473b..108462a 100644 --- a/layouts/partials/academy-validation/collect-content-health.html +++ b/layouts/partials/academy-validation/collect-content-health.html @@ -69,7 +69,11 @@ {{- $fix := "" -}} {{- $registryStatus := "" -}} {{- $cloudStatus := "" -}} - {{- $isDraft := or .Draft (eq (printf "%v" .Params.draft | lower) "true") -}} + {{- /* A page only carries a Hugo draft flag inside $site.Pages when the build + itself included drafts (hugo --buildDrafts). Treat that as "draft mode on" + for this content: it is being rendered, so validate it softly below. */ -}} + {{- $draftBuilt := or .Draft (eq (printf "%v" .Params.draft | lower) "true") -}} + {{- $isDraft := $draftBuilt -}} {{- if not $isDraft -}} {{- $sourcePath := printf "content/%s" $filePath -}} {{- $source := try (os.ReadFile $sourcePath) -}} @@ -85,7 +89,14 @@ {{- $draft = add $draft 1 -}} {{- end -}} - {{- if not (partial "academy-validation/validate-academy-org-id.html" $orgID) -}} + {{- if and $isDraft (not $draftBuilt) -}} + {{- /* Content is marked draft but the build's draft mode is off (Hugo is not + rendering it). Respect the build mode and skip validation entirely so we + never check or warn on draft modules that are not part of this build. */ -}} + {{- $status = "draft" -}} + {{- $issue = "Draft content is not validated while the build's draft mode is off." -}} + {{- $fix = "Build with drafts enabled (--buildDrafts) to validate this draft, or publish it." -}} + {{- else if not (partial "academy-validation/validate-academy-org-id.html" $orgID) -}} {{- $status = "broken" -}} {{- $issue = "Content is outside a valid organization directory." -}} {{- $fix = "Move this root content under content////." -}} @@ -117,7 +128,7 @@ {{- end -}} {{- end -}} - {{- if and $isDraft (ne $status "good") -}} + {{- if and $draftBuilt (ne $status "good") -}} {{- $status = "draft_warning" -}} {{- if eq $issue "" -}} {{- $issue = "Draft content could not be fully validated." -}} diff --git a/layouts/shortcodes/instructor-toolkit.html b/layouts/shortcodes/instructor-toolkit.html index ffec534..248140e 100644 --- a/layouts/shortcodes/instructor-toolkit.html +++ b/layouts/shortcodes/instructor-toolkit.html @@ -106,6 +106,8 @@ ✅ {{- else if eq .status "unchecked" -}} Not checked + {{- else if eq .status "draft" -}} + Draft {{- else -}} {{- if ne $consoleURL "" -}}{{- else -}}❌{{- end -}} {{- end -}}