You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I edited the post_meta.html with codes below to add taxonomies in a similar style. But with my code, the meta data would become quite messy when the site is opened on my phone or in a tightened web size, as show in the attached picture.
`
{{- $scratch := newScratch }}
{{- if .Params.categories -}}
{{- range $index, $value := ($.GetTerms "categories") }}
{{- if eq $index 0}}
{{ .LinkTitle }}
{{- else }}
/{{ .LinkTitle }}
{{- end }}
{{- end }}
·
{{- end }}
{{- if .Params.tags -}}
{{- range $index, $value := ($.GetTerms "tags") }}
{{- if eq $index 0}} {{ .LinkTitle }}
{{- else }} /{{ .LinkTitle }}
{{- end }}
{{- end }}
·
{{- end }}
{{- if not .Date.IsZero -}}
{{- $scratch.Add "meta" (slice (printf "published %s" (.Date) (.Date | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
{{- end }}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I edited the post_meta.html with codes below to add taxonomies in a similar style. But with my code, the meta data would become quite messy when the site is opened on my phone or in a tightened web size, as show in the attached picture.
`
{{- $scratch := newScratch }}
{{- if .Params.categories -}}
{{- range $index,$value := ($ .GetTerms "categories") }}
{{- if eq $index 0}}
{{ .LinkTitle }}
{{- else }}
/{{ .LinkTitle }}
{{- end }}
{{- end }}
· {{- end }}{{- if .Params.tags -}}
{{- range $index,
{{- if eq $index 0}}
{{ .LinkTitle }}
{{- else }}
/{{ .LinkTitle }}
{{- end }}
{{- end }}
{{- if not .Date.IsZero -}}
{{- $scratch.Add "meta" (slice (printf "published %s" (.Date) (.Date | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
{{- end }}
{{- if (.Param "ShowLastMod") -}}
{{- $scratch.Add "meta" (slice (printf "modified %s" (.Lastmod.Format (.Site.Params.dateFormat | default "2006-01-02")))) }}
{{- end }}
{{- if (.Param "ShowReadingTime") -}}
{{- $scratch.Add "meta" (slice (i18n "read_time" .ReadingTime | default (printf "%d min" .ReadingTime))) }}
{{- end }}
{{- if (.Param "ShowWordCount") -}}
{{- $scratch.Add "meta" (slice (i18n "words" .WordCount | default (printf "%d words" .WordCount))) }}
{{- end }}
{{- with (partial "author.html" .) }}
{{- $scratch.Add "meta" (slice .) }}
{{- end }}
{{- with ($scratch.Get "meta") }}
{{- delimit . " · " -}}
{{- end -}}
`
Is it possible to modify the code for categories&tags, fitting them into the overall {{- $scratch.Add "meta" <some_codes_here }}{{- end }} coding?
Beta Was this translation helpful? Give feedback.
All reactions