My personal website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
1.1 KiB

{{- /*
-- Returns the description of a page (plain text), used by the meta
-- description, Open Graph, Twitter cards and structured data.
--
-- In order of preference:
-- 1. the "description" front matter parameter
-- 2. the description of the site, for the home page
-- 3. "Articles related to <term>" for the taxonomy term pages
-- 4. the summary of the page, truncated to ~160 characters
-- 5. the description of the site
-- 6. the title of the page
*/ -}}
{{- $description := "" -}}
{{- if .Description -}}
{{- $description = .Description -}}
{{- else if and .IsHome site.Params.description -}}
{{- $description = site.Params.description -}}
{{- else if eq .Kind "term" -}}
{{- $description = printf "%s %s" (i18n "articles_related_to" | strings.TrimSpace) .Title -}}
{{- else -}}
{{- $summary := .Summary | plainify | htmlUnescape | replaceRE `\s+` " " | strings.TrimSpace -}}
{{- with $summary -}}
{{- $description = truncate 160 . -}}
{{- else -}}
{{- $description = or site.Params.description .Title -}}
{{- end -}}
{{- end -}}
{{- return ($description | plainify | htmlUnescape | strings.TrimSpace) -}}