Add a set of templates to generate an Atom feed!
This commit is contained in:
		
							parent
							
								
									2c432932db
								
							
						
					
					
						commit
						641fd8ccbf
					
				
					 4 changed files with 53 additions and 0 deletions
				
			
		
							
								
								
									
										28
									
								
								layouts/_default/index.atom.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								layouts/_default/index.atom.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
{{- $pctx := . -}}
 | 
			
		||||
{{- if .IsHome -}} {{ $pctx = .Site }} {{- end -}}
 | 
			
		||||
{{- $pages := slice -}}
 | 
			
		||||
{{- if or $.IsHome $.IsSection -}}
 | 
			
		||||
  {{- $pages = $pctx.RegularPages -}}
 | 
			
		||||
{{- else -}}
 | 
			
		||||
  {{- $pages = $pctx.Pages -}}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
{{- $limit := .Site.Config.Services.RSS.Limit -}}
 | 
			
		||||
{{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} {{- end -}}
 | 
			
		||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
 | 
			
		||||
<feed xmlns="http://www.w3.org/2005/Atom">
 | 
			
		||||
  <title>{{ .Site.Title }}</title>
 | 
			
		||||
  <link href="{{ `/feed.xml` | absURL }}" rel="self" />
 | 
			
		||||
  <link href="{{ .Permalink }}" />
 | 
			
		||||
  {{ if not .Date.IsZero }}<updated>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>{{ end }}
 | 
			
		||||
  <id>{{ .Permalink }}</id>
 | 
			
		||||
  {{ with .Site.Author.name }}
 | 
			
		||||
  <author>
 | 
			
		||||
    <name>{{ . }}</name>
 | 
			
		||||
    {{ with $.Site.Author.email }}<email>{{ . }}</email>{{ end }}
 | 
			
		||||
    <uri>{{ $.Site.Home.Permalink }}</uri>
 | 
			
		||||
  </author>
 | 
			
		||||
  {{ end }}
 | 
			
		||||
  <generator version="{{ hugo.Version }}" uri="https://gohugo.io">Hugo {{ hugo.Version }}</generator>
 | 
			
		||||
  <rights>© {{ now.Year }} Eryn Wells</rights>
 | 
			
		||||
  {{ range $pages }}{{ .Render "atom_entry" }}{{ end }}
 | 
			
		||||
</feed>
 | 
			
		||||
							
								
								
									
										6
									
								
								layouts/blog/atom_entry.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								layouts/blog/atom_entry.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
<entry>
 | 
			
		||||
  {{ partial "atom_entry_metadata.xml" . }}
 | 
			
		||||
  {{- if .Content -}}
 | 
			
		||||
  {{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}]]></content>
 | 
			
		||||
  {{- end -}}
 | 
			
		||||
</entry>
 | 
			
		||||
							
								
								
									
										11
									
								
								layouts/partials/atom_entry_metadata.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								layouts/partials/atom_entry_metadata.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
<title>{{ .Title }}</title>
 | 
			
		||||
<id>{{ .Permalink }}</id>
 | 
			
		||||
{{ with .Site.Author.name }}<author><name>{{ . }}</name></author>{{ end }}
 | 
			
		||||
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
 | 
			
		||||
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
 | 
			
		||||
{{- range slice "series" "categories" "tags" -}}
 | 
			
		||||
  {{- range $.GetTerms . -}}
 | 
			
		||||
  {{ $scheme := (.Site.GetPage (printf "/%s" .Section)).Permalink }}
 | 
			
		||||
  <category term="{{ .Name }}" scheme="{{ $scheme }}" label="{{ .Title }}" />
 | 
			
		||||
  {{- end -}}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
							
								
								
									
										8
									
								
								layouts/photos/atom_entry.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								layouts/photos/atom_entry.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
{{- $thumbnail := partial "images/photo_thumbnail.html" . -}}
 | 
			
		||||
<entry>
 | 
			
		||||
  {{ partial "atom_entry_metadata.xml" . }}
 | 
			
		||||
  <link rel="enclosure" href="{{ $thumbnail.Permalink }}" type="{{ $thumbnail.MediaType }}" length="{{ len $thumbnail.Content }}" />
 | 
			
		||||
  {{ if .Content }}
 | 
			
		||||
  {{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}]]></content>
 | 
			
		||||
  {{ end }}
 | 
			
		||||
</entry>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue