{{ $ := index . "$" }}
{{ $isHome := .isHome }}
<div class="post-meta">
    {{ if and $.Site.Params.displayPublishedDate (not $.PublishDate.IsZero) }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.publishedDateIcon "class" "post-meta-icon") }}
        <time datetime="{{ $.PublishDate.Format "2006-01-02T15:04:05-07:00" }}" class="post-meta-item published dt-published">{{ $icon }}&nbsp;{{ $.PublishDate.Format $.Site.Params.postMetaDateFormat }}</time>
    {{ end }}
    {{ if and $.Site.Params.displayModifiedDate (not $.Lastmod.IsZero) }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.modifiedDateIcon "class" "post-meta-icon") }}
        <time datetime="{{ $.Lastmod.Format "2006-01-02T15:04:05-07:00" }}" class="post-meta-item modified dt-updated">{{ $icon }}&nbsp;{{ $.Lastmod.Format $.Site.Params.postMetaDateFormat }}</time>
    {{ end }}
    {{ if and $.Site.Params.displayExpiredDate (not $.ExpiryDate.IsZero) }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.expiredDateIcon "class" "post-meta-icon") }}
        <time datetime="{{ $.ExpiryDate.Format "2006-01-02T15:04:05-07:00" }}" class="post-meta-item expired">{{ $icon }}&nbsp;{{ $.ExpiryDate.Format $.Site.Params.postMetaDateFormat }}</time>
    {{ end }}
    {{ if $.Site.Params.displayCategory }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.categoryIcon "class" "post-meta-icon") }}
        {{ if and (eq $.Site.Params.categoryBy "sections") (in $.Site.Params.mainSections $.Section) }}
            {{ $sections := split (strings.TrimSuffix "/" ($.File.Dir | default $.Section)) "/" }}
            {{ with $sections }}
                {{ $.Scratch.Delete "sectionsDirMeta" }}
                {{ $.Scratch.Delete "sectionsMeta" }}
                {{ $.Scratch.Set "index" 0 }}
                {{ range $sections }}
                    {{ $section := . }}
                    {{ $.Scratch.Add "sectionsDirMeta" (printf `/%s` $section) }}
                    {{ with $.Site.GetPage ($.Scratch.Get "sectionsDirMeta") }}
                        {{ if (eq .Kind "section") }}
                            {{ $.Scratch.SetInMap "sectionsMeta" (printf `%s/%s` (string ($.Scratch.Get "index")) .RelPermalink) (.LinkTitle | default $section) }}
                            {{ $.Scratch.Set "index" (add ($.Scratch.Get "index") 1) }}
                        {{ end }}
                    {{ end }}
                {{ end }}
            {{ end }}
            {{ $sections := $.Scratch.Get "sectionsMeta" }}
            {{ with $sections }}
                <span class="post-meta-item category">
                    {{- $icon -}}&nbsp;
                    {{- range $link, $title := $sections -}}
                        {{- $index := $link | replaceRE `(\d+)/.+` `$1` | int -}}
                        {{- if ne $index 0 }}
                            {{- $.Site.Params.categoryDelimiter | default "/" -}}
                        {{- end -}}
                        <a href="{{- $link | replaceRE `\d+/(.+)` `$1` -}}" class="category-link p-category">
                            {{- $title -}}
                        </a>
                    {{- end -}}
                </span>
            {{ end }}
        {{ end }}
        {{ if eq $.Site.Params.categoryBy "categories" }}
            {{ with $.Params.categories }}
                <span class="post-meta-item category">
                    {{- $icon -}}&nbsp;
                    {{- range $index, $category := . -}}
                        {{- if ne $index 0 -}}
                            {{- $.Site.Params.categoryDelimiter | default "/" -}}
                        {{- end -}}
                        <!-- Work-around for https://github.com/gohugoio/hugo/issues/6546 -->
                        {{- $path := (urls.Parse ($category | urlize)).Path -}}
                        {{- with $.Site.GetPage (printf `/categories/%s` $path) -}}
                            <a href="{{- .RelPermalink -}}" class="category-link p-category">
                                {{- .LinkTitle | default $path -}}
                            </a>
                        {{- end -}}
                    {{- end -}}
                </span>
            {{ end }}
        {{ end }}
    {{ end }}
    {{ if $.Site.Params.displayWordCount }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.wordCountIcon "class" "post-meta-icon") }}
        <span class="post-meta-item wordcount">{{ $icon }}&nbsp;{{ $.WordCount }}</span>
    {{ end }}
    {{ if $.Site.Params.displayReadingTime }}
        {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.readingTimeIcon "class" "post-meta-icon") }}
        <span class="post-meta-item reading-time">{{ $icon }}&nbsp;{{ $.ReadingTime }}&nbsp;{{ i18n "minute" $.ReadingTime }}</span>
    {{ end }}
    {{ if and $.Site.Params.displayBusuanziPagePV (eq hugo.Environment "production") }}
        {{ if not $isHome }}
            {{ $icon := partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.busuanziPagePVIcon "class" "post-meta-icon") }}
            <span class="post-meta-item busuanzi-page-pv" id="busuanzi_container_page_pv">{{ $icon }}&nbsp;<span id="busuanzi_value_page_pv"></span></span>
        {{ end }}
    {{ end }}
    {{ partial "custom/post-meta.html" $ }}
</div>