From a5dd8e0435a9888280cf3b29c393ae824862ad42 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Fri, 7 Nov 2025 16:01:25 +0000 Subject: [PATCH 1/2] DOC-5922 try adding JSON metadata --- .../_markup/render-codeblock-checklist.html | 42 +++++++++++ static/schemas/checklist.json | 69 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 static/schemas/checklist.json diff --git a/layouts/_default/_markup/render-codeblock-checklist.html b/layouts/_default/_markup/render-codeblock-checklist.html index cd0f490ba..09649eb60 100644 --- a/layouts/_default/_markup/render-codeblock-checklist.html +++ b/layouts/_default/_markup/render-codeblock-checklist.html @@ -1,4 +1,46 @@ {{- $id := .Attributes.id | default "checklist" -}} +{{- $title := .Attributes.title | default "" -}} +{{- $description := .Attributes.description | default "" -}} + +{{- /* Parse checklist items from markdown */ -}} +{{- $items := slice -}} +{{- $position := 0 -}} +{{- range split .Inner "\n" -}} + {{- $line := trim . " " -}} + {{- if and (ne $line "") (hasPrefix $line "- [") -}} + {{- $position = add $position 1 -}} + {{- /* Extract link and text */ -}} + {{- $linkPattern := `\[([^\]]+)\]\(([^\)]+)\)` -}} + {{- $matches := findRE $linkPattern $line -}} + {{- if $matches -}} + {{- $fullMatch := index $matches 0 -}} + {{- $textMatch := findRE `\[([^\]]+)\]` $fullMatch -}} + {{- $urlMatch := findRE `\(([^\)]+)\)` $fullMatch -}} + {{- $text := trim (index $textMatch 0) "[]" -}} + {{- $url := trim (index $urlMatch 0) "()" -}} + {{- $item := dict "position" $position "name" $text "url" $url -}} + {{- $items = $items | append $item -}} + {{- else -}} + {{- /* Item without link */ -}} + {{- $text := replaceRE `^- \[[\sx]\]\s*` "" $line -}} + {{- $item := dict "position" $position "name" $text -}} + {{- $items = $items | append $item -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- /* Build metadata object */ -}} +{{- $metadata := dict "type" "checklist" "id" $id "items" $items -}} +{{- if ne $title "" -}} + {{- $metadata = merge $metadata (dict "title" $title) -}} +{{- end -}} +{{- if ne $description "" -}} + {{- $metadata = merge $metadata (dict "description" $description) -}} +{{- end -}} +{{- $metadata = merge $metadata (dict "$schema" "https://redis.io/schemas/checklist.json") -}} +
{{ .Inner | htmlEscape | safeHTML }}
+{{ printf "" ($metadata | jsonify (dict "indent" " ")) | safeHTML }} + {{ .Page.Store.Set "hasChecklist" true }} diff --git a/static/schemas/checklist.json b/static/schemas/checklist.json new file mode 100644 index 000000000..21bd7bd7b --- /dev/null +++ b/static/schemas/checklist.json @@ -0,0 +1,69 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://redis.io/schemas/checklist.json", + "title": "Redis Checklist Metadata", + "description": "Schema for checklist metadata in Redis documentation", + "type": "object", + "required": ["type", "id", "items"], + "properties": { + "$schema": { + "type": "string", + "description": "Reference to this schema" + }, + "type": { + "type": "string", + "enum": ["checklist"], + "description": "The metadata type" + }, + "id": { + "type": "string", + "description": "Unique identifier for the checklist" + }, + "title": { + "type": "string", + "description": "Human-readable title of the checklist" + }, + "description": { + "type": "string", + "description": "Description of what the checklist covers" + }, + "items": { + "type": "array", + "description": "Array of checklist items", + "items": { + "type": "object", + "required": ["position", "name"], + "properties": { + "position": { + "type": "integer", + "description": "Order in the checklist (1-based)" + }, + "name": { + "type": "string", + "description": "Item text" + }, + "url": { + "type": "string", + "description": "Link to the relevant section (can be relative or absolute)" + }, + "optional": { + "type": "boolean", + "description": "Whether this step is optional" + }, + "estimatedTime": { + "type": "string", + "description": "Estimated time to complete this step (e.g., '5 minutes', '1 hour')" + }, + "prerequisites": { + "type": "array", + "description": "List of prerequisite item positions that must be completed first", + "items": { + "type": "integer" + } + } + } + } + } + } +} + From 945125287b23a0c2eb2b228720264a252ab12fc3 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Fri, 7 Nov 2025 16:32:23 +0000 Subject: [PATCH 2/2] DOC-5922 belt-and-braces metadata for the very picky ChatGPT crawler --- layouts/_default/_markup/render-codeblock-checklist.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/layouts/_default/_markup/render-codeblock-checklist.html b/layouts/_default/_markup/render-codeblock-checklist.html index 09649eb60..912ea0d9c 100644 --- a/layouts/_default/_markup/render-codeblock-checklist.html +++ b/layouts/_default/_markup/render-codeblock-checklist.html @@ -40,7 +40,12 @@ {{- $metadata = merge $metadata (dict "$schema" "https://redis.io/schemas/checklist.json") -}}
{{ .Inner | htmlEscape | safeHTML }}
-{{ printf "" ($metadata | jsonify (dict "indent" " ")) | safeHTML }} + +{{ $jsonMetadata := $metadata | jsonify (dict "indent" " ") }} + +{{ printf "" $jsonMetadata | safeHTML }} + +{{ printf "" $jsonMetadata | safeHTML }} {{ .Page.Store.Set "hasChecklist" true }}