-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial support for feed.json
Close #879
- Loading branch information
1 parent
68e50e4
commit 4a810e0
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
|
||
["text/plain"] | ||
suffixes = ["md"] | ||
|
||
["application/feed+json"] | ||
suffixes = ["feed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Options to make hugo output files | ||
# 用于 Hugo 输出文档的设置 | ||
|
||
home = ["HTML", "RSS", "JSON"] | ||
home = ["HTML", "RSS", "JSON", "JsonFeed"] | ||
page = ["HTML", "MarkDown"] | ||
section = ["HTML", "RSS"] | ||
taxonomy = ["HTML", "RSS"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ $list := .Pages -}} | ||
{{ $length := (len $list) -}} | ||
{ | ||
"version" : "https://jsonfeed.org/version/1.1", | ||
"title" : "{{- .Site.Title -}}", | ||
"description": "{{- .Site.Params.description | default .Site.Title -}}", | ||
"home_page_url" : "{{ .Site.BaseURL }}", | ||
{{ with .OutputFormats.Get "JsonFeed" -}} | ||
"feed_url" : "{{ .Permalink }}", | ||
{{ end -}} | ||
"icon" : "{{ `/apple-touch-icon.png` | absURL }}", | ||
"favicon" : "{{ `/favicon.ico` | absURL }}", | ||
{{ with .Site.Author.name -}} | ||
"author" : { | ||
"name" : "{{ . }}"{{ with $.Site.Author.link }}, | ||
"url": "{{ . }}"{{ end }}{{ with $.Site.Author.avatar }}, | ||
"avatar": "{{ . | absURL }}"{{ end }} | ||
}, | ||
{{ end -}} | ||
"items" : [ | ||
{{ range $index, $element := where .Site.RegularPages "Type" "in" site.Params.mainSections -}} | ||
{ | ||
"title" : {{ .Title | jsonify }}, | ||
"date_published" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}", | ||
{{ if .Lastmod -}} | ||
"date_modified" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}", | ||
{{ else -}} | ||
"date_modified" : "{{ .LastMod.Format "2006-01-02T15:04:05Z07:00" }}", | ||
{{ end -}} | ||
"id" : "{{ .Permalink }}", | ||
"url" : "{{ .Permalink }}", | ||
{{ with .Summary -}} | ||
"summary": {{ . | plainify | jsonify }}, | ||
{{ end -}} | ||
{{ with .Params.author -}} | ||
"author" : { | ||
"name" : "{{ . }}" | ||
}, | ||
{{ end -}} | ||
"content_html" : {{ .Content | jsonify }}, | ||
"language": {{ .Language.Lang | default $.Lang | jsonify }} | ||
}{{ if ne (add $index 1) $length }},{{ end }} | ||
{{ end -}} | ||
] | ||
} |