yamt

YAMT: Yet Another Minimal Theme for Hugo
git clone https://git.ckiri.com/yamt.git
Log | Files | Refs | LICENSE

rss.xml (2413B)


      1 {{- $authorEmail := "" }}
      2 {{- with site.Params.author }}
      3   {{- if reflect.IsMap . }}
      4     {{- with .email }}
      5       {{- $authorEmail = . }}
      6     {{- end }}
      7   {{- end }}
      8 {{- end }}
      9 
     10 {{- $authorName := "" }}
     11 {{- with site.Params.author }}
     12   {{- if reflect.IsMap . }}
     13     {{- with .name }}
     14       {{- $authorName = . }}
     15     {{- end }}
     16   {{- else }}
     17     {{- $authorName  = . }}
     18   {{- end }}
     19 {{- end }}
     20 
     21 {{- $pctx := . }}
     22 {{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
     23 {{- $pages := slice }}
     24 {{- if or $.IsHome $.IsSection }}
     25 {{- $pages = $pctx.RegularPages }}
     26 {{- else }}
     27 {{- $pages = $pctx.Pages }}
     28 {{- end }}
     29 {{- $limit := .Site.Config.Services.RSS.Limit }}
     30 {{- if ge $limit 1 }}
     31 {{- $pages = $pages | first $limit }}
     32 {{- end }}
     33 {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
     34 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
     35   <channel>
     36   <title>{{ T "section" }}: "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }}" {{ T "on" }} {{ end }}{{ .Site.Title }}{{ end }}</title>
     37     <link>{{ .Permalink }}</link>
     38     <description>{{ T "recent" }} {{ if ne .Title .Site.Title }}{{ with .Title }}in "{{ . }}" {{ end }}{{ end }}{{ T "on" }} {{ .Site.Title }}</description>
     39     <generator>Hugo</generator>
     40     <language>{{ site.Language.Locale }}</language>{{ with $authorEmail }}
     41     <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
     42     <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
     43     <copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
     44     <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
     45     {{- with .OutputFormats.Get "RSS" }}
     46     {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
     47     {{- end }}
     48     {{- range $pages }}
     49     <item>
     50       <title>{{ .Title }}</title>
     51       <link>{{ .Permalink }}</link>
     52       <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
     53       {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
     54       <guid>{{ .Permalink }}</guid>
     55       <description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
     56     </item>
     57     {{- end }}
     58   </channel>
     59 </rss>