diff --git a/config.toml b/config.toml index 2752ff5264..0d62ccc8ec 100644 --- a/config.toml +++ b/config.toml @@ -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"] \ No newline at end of file +page = ["HTML", "Markdown", "JSON"] + +# Content negotiation headers (hugo serve only). +# For production nginx config see AI_AGENT_DEVELOPER_GUIDE.md. +# 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" \ No newline at end of file diff --git a/layouts/home.json b/layouts/home.json new file mode 100644 index 0000000000..0740cc4607 --- /dev/null +++ b/layouts/home.json @@ -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 -}} + {{- 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 }} +} diff --git a/layouts/home.md b/layouts/home.md new file mode 100644 index 0000000000..5522dc7098 --- /dev/null +++ b/layouts/home.md @@ -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 }}