Files
tplate/web/templates/xml/atom.tmpl

37 lines
1.5 KiB
Cheetah

{{- define "xml/atom" }}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ .Config.Title }}</title>
<id>{{ print .Config.URL `/atom.xml` }}</id>
<link href="{{ print .Config.URL `/atom.xml` }}" rel="self" type="application/atom+xml" />
<link href="{{ .Config.URL }}" rel="alternate" type="text/html"/>
<updated>{{ "2006-01-02T15:04:05Z07:00" | .Time.Format }}</updated>
<author><name>{{ .Config.Author }}</name></author>
{{ range .Posts -}}
{{- /* 跳过隐藏或外部的文章 */ -}}
{{ if and (not (and .FM.ParsedFlags.ExternalPost .FM.URL)) (or (not .FM.ParsedFlags.HidePost) .FM.ParsedFlags.ShowInRSSAndSitemap) -}}
{{ $targetDate := "" -}}
{{ if .FM.Updated -}}
{{ $targetDate = "2006-01-02T15:04:05Z07:00" | .FM.TimeUpdated.Format }}
{{- else if .FM.Date -}}
{{ $targetDate = "2006-01-02T15:04:05Z07:00" | .FM.TimeDate.Format }}
{{- end -}}
<entry>
<title>{{ .FM.Title }}</title>
<id>{{ print $.Config.URL .FM.URI }}</id>
<link href="{{ print $.Config.URL .FM.URI }}"/>
{{ if $targetDate }}<updated>{{ $targetDate }}</updated>{{ end }}
{{ if .FM.Author -}}
<author>
<name>{{ .FM.Author }}</name>
{{ if .FM.AuthorLink }}<uri>{{ .FM.AuthorLink }}</uri>{{ end }}
</author>
{{- end }}
{{ if .FM.Summary }}<summary>{{ .FM.Summary }}</summary>{{ end }}
{{ .FM.ParsedFlags.SetForRSS -}}
<content type="html">{{ .RenderContent }}</content>
</entry>
{{ end }}
{{- end }}
</feed>
{{- end }}