{{- $.Scratch.Add "index" slice -}}

{{- range $name, $taxonomy := .Site.Taxonomies.categories -}}
    {{- $.Scratch.Add "index" (dict "url" (print "/categories/" $name | absURL) "title" ($name | humanize) "iconClass" "fa-folder" "type" "category" "objectID" (print "/categories/" $name | absURL) ) -}}
{{- end -}}

{{- range $name, $taxonomy := .Site.Taxonomies.author -}}
    {{- $.Scratch.Add "index" (dict "url" (print "/author/" $name | absURL) "title" ($name | humanize) "iconClass" "fa-user" "type" "author" "objectID" (print "/author/" $name | absURL) ) -}}
{{- end -}}

{{- range $name, $taxonomy := .Site.Taxonomies.tags -}}
    {{- $.Scratch.Add "index" (dict "url" (print "/tags/" $name | absURL) "title" ($name | humanize) "iconClass" "fa-tag" "type" "tag" "objectID" (print "/tags/" $name | absURL) ) -}}
{{- end -}}

{{- range where .Pages "Type" "not in"  (slice "page" "json") -}}

    {{- range .Translations -}}

        {{- .Scratch.Set "iconClass" "fa-pencil" -}}
        {{- if eq .Type "quote" -}}
            {{- .Scratch.Set "iconClass" "fa-quote-right" -}}
        {{- else if eq .Type "link" -}}
            {{- .Scratch.Set "iconClass" "fa-link" -}}
        {{- else if eq .Type "video" -}}
            {{- .Scratch.Set "iconClass" "fa-video-camera" -}}
        {{- else if or (eq .Type "gallery") (eq .Type "picture") -}}
            {{- .Scratch.Set "iconClass" "fa-camera" -}}
        {{- else if eq .Type "audio" -}}
            {{- .Scratch.Set "iconClass" "fa-music" -}}
        {{- end -}}

        {{- $.Scratch.Add "index" (dict "url" .Permalink "title" .Title "tags" .Params.tags "categories" .Params.categories "author" .Params.author "type" .Type "language" .Lang "iconClass" (.Scratch.Get "iconClass") "objectID" (.Permalink | md5) ) -}}
    {{- end -}}
{{- end -}}

{{- $.Scratch.Get "index" | jsonify -}}
