Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions layouts/_default/_markup/render-codeblock-checklist.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,51 @@
{{- $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") -}}

<pre class="checklist-source" data-checklist-id="{{ $id }}">{{ .Inner | htmlEscape | safeHTML }}</pre>

{{ $jsonMetadata := $metadata | jsonify (dict "indent" " ") }}

{{ printf "<script type=\"application/json\" data-redis-metadata=\"checklist\">\n%s\n</script>" $jsonMetadata | safeHTML }}

{{ printf "<template data-redis-metadata=\"checklist\">\n%s\n</template>" $jsonMetadata | safeHTML }}

{{ .Page.Store.Set "hasChecklist" true }}

69 changes: 69 additions & 0 deletions static/schemas/checklist.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}
}