{{- /*
Breadcrumbs trail + BreadcrumbList schema.org JSON-LD.
Gated by params.breadcrumbs.enable (default off for backwards compat).
Skipped on home; renders Home → Section → Page for posts, Home → Section for section listings.
*/ -}}
{{- if site.Params.breadcrumbs.enable -}}
{{- if not .IsHome -}}
{{- $home := site.Home -}}
{{- $section := .CurrentSection -}}
{{- $isSection := and $section (ne $section.RelPermalink $home.RelPermalink) (ne $section.RelPermalink .RelPermalink) -}}
{{- $isLeaf := and (eq .Kind "page") $isSection -}}
{{- $homeName := i18n "breadcrumbHome" | default "Home" -}}
{{- $items := slice (dict "@type" "ListItem" "position" 1 "name" $homeName "item" $home.Permalink) -}}
{{- if $isSection -}}
{{- $items = $items | append (dict "@type" "ListItem" "position" 2 "name" ($section.LinkTitle | default $section.Title) "item" $section.Permalink) -}}
{{- end -}}
{{- if $isLeaf -}}
{{- $items = $items | append (dict "@type" "ListItem" "position" 3 "name" (.LinkTitle | default .Title) "item" .Permalink) -}}
{{- end -}}
{{- $bc := dict "@context" "https://schema.org" "@type" "BreadcrumbList" "itemListElement" $items -}}
{{- end -}}
{{- end -}}