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
18 changes: 17 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,21 @@ rdi_current_version = "1.18.1"

# Comment out if you don't want the "print entire section" link enabled.
[outputs]
home = ["HTML", "RSS", "Markdown", "JSON"]
section = ["HTML", "RSS", "Markdown", "JSON"]
page = ["HTML", "Markdown", "JSON"]
page = ["HTML", "Markdown", "JSON"]

# Content negotiation headers (hugo serve only).
# For production nginx config see AI_AGENT_DEVELOPER_GUIDE.md.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is outdated now

# Must be at end of file — TOML [table] sections apply to all following keys.
[server]
[[server.headers]]
for = "/**"
[server.headers.values]
Vary = "Accept"

[[server.headers]]
for = "**.html.md"
[server.headers.values]
Content-Type = "text/markdown; charset=utf-8"
Vary = "Accept"
36 changes: 36 additions & 0 deletions layouts/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- /* AI-friendly JSON output for the home page */ -}}

{{- $content := partial "process-markdown-content.html" (dict "RawContent" .RawContent "Site" .Site "Page" .) -}}

{{- $summary := (.Params.description | default .Description) | plainify | replaceRE "\\s+" " " | strings.TrimSpace -}}
{{- $tags := .Params.categories | default (slice) -}}
{{- $lastUpdated := .Lastmod.Format "2006-01-02T15:04:05Z07:00" -}}

{{- $children := slice -}}
{{- range .Pages -}}
{{- $childId := "" -}}
{{- with .File -}}
{{- $baseName := .ContentBaseName -}}
{{- if or (not $baseName) (eq $baseName "_index") -}}
{{- $childId = $.Title | urlize -}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong child id in loop

Medium Severity

In the children loop, when a child’s ContentBaseName is missing or _index, id is set from $.Title (the home page) instead of the child page’s title. Top-level section entries can share the same wrong id in home index.json, which misleads consumers of the JSON/NDJSON feed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d92baf2. Configure here.

{{- else -}}
{{- $childId = $baseName | urlize -}}
{{- end -}}
{{- else -}}
{{- $childId = .Title | urlize -}}
{{- end -}}
{{- $childSummary := (.Params.description | default .Description) | plainify | replaceRE "\\s+" " " | strings.TrimSpace -}}
{{- $child := dict "id" $childId "title" .Title "url" .Permalink "summary" $childSummary -}}
{{- $children = $children | append $child -}}
{{- end -}}

{
"id": "home",
"title": {{ .Title | jsonify }},
"url": {{ .Permalink | jsonify }},
"summary": {{ $summary | jsonify }},
"content": {{ $content | jsonify }},
"tags": {{ $tags | jsonify }},
"last_updated": {{ $lastUpdated | jsonify }},
"children": {{ $children | jsonify }}
}
16 changes: 16 additions & 0 deletions layouts/home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# {{ .Title }}

```json metadata
{
"title": {{ .Title | jsonify }},
"description": {{ (.Params.description | default .Description) | plainify | replaceRE "\\s+" " " | strings.TrimSpace | jsonify }},
"categories": {{ .Params.categories | jsonify }},
"tableOfContents": {{ partial "toc-from-markdown.html" . }},
"codeExamples": {{ partial "code-examples-json.html" . }}
}
```

{{- /* Process content with shared partial (shortcode expansion, HTML unescaping, etc.) */ -}}
{{- $content := partial "process-markdown-content.html" (dict "RawContent" .RawContent "Site" .Site "Page" .) -}}

{{ $content }}
Loading