Skip to content

Commit

Permalink
Add atom feed xml
Browse files Browse the repository at this point in the history
  • Loading branch information
klknn committed Aug 24, 2022
1 parent 0bfeb5e commit afb831f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
baseURL = "https://klknn.github.io/"
languageCode = "ja"
title = "klknn log"
summaryLength = 300

[params]
author = "klknn"
editURL = "https://github.com/klknn/klknn.github.io/edit/develop/content"

3 changes: 3 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ block "title" . }}{{ end }}</title>
<link rel="stylesheet" type="text/css" href="{{ relURL "/main.css" }}">
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="application/atom" href="%s" title="Atom" />` .Rel .Permalink | safeHTML }}
{{ end -}}
<script>
MathJax = {
tex: {
Expand Down
37 changes: 37 additions & 0 deletions layouts/index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- $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" xml:lang="ja">
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>

<link>{{ .Permalink }}</link>
<updated>{{ time.Format "2006-01-02T15:04:05-0700" .Site.LastChange | safeHTML }}</updated>
<author>
<name>{{ $.Site.Params.author }}</name>
</author>
<generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>
<id>{{ .Permalink }}</id>

{{ range $pages }}
<entry>
<title>{{ .Title }}</title>
<link href="{{ .Permalink }}"/>
<id>{{ .Permalink }}</id>
<published>{{ .PublishDate.Format "2006-01-02T15:04:05-0700" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-0700" | safeHTML }}</updated>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<summary type="html">{{ .Summary | htmlEscape }}...</summary>
<content type="html">{{ .Content | htmlEscape }}</content>
</entry>
{{ end }}
</feed>

0 comments on commit afb831f

Please sign in to comment.