summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--exampleSite/config.toml13
-rw-r--r--layouts/_default/home.atom.xml3
-rw-r--r--layouts/_default/home.feed.xml11
-rw-r--r--layouts/_default/home.json.json26
-rw-r--r--theme.toml25
5 files changed, 57 insertions, 21 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 3e57fe9..5a3ae85 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -16,9 +16,8 @@ disableKinds = ['RSS']
[outputs]
# TODO:
- # home = [ "HTML", "Atom", "JSON", "humanstxt" ]
# section = [ "HTML", "Atom" ]
- home = [ 'HTML', 'Atom', 'FEED', 'humanstxt' ]
+ home = [ 'HTML', 'Atom', 'FEED', 'JSON', 'humanstxt' ]
# Atom feed.
# For more see: https://validator.w3.org/feed/docs/atom.html#whatIsAtom
@@ -51,6 +50,16 @@ disableKinds = ['RSS']
noUgly = true
permalinkable = false
+# For more see: https://www.jsonfeed.org/
+[outputFormats.JSON]
+ name = 'Json'
+ mediaType = 'application/json'
+ baseName = 'feeds/feed'
+ rel = 'alternate'
+ isPlainText = true
+ isHTML = false
+ noUgly = false
+
# For more see: https://gohugo.io/templates/output-formats/
[outputFormats.humanstxt]
mediaType = 'text/plain'
diff --git a/layouts/_default/home.atom.xml b/layouts/_default/home.atom.xml
index 5368ab7..45af5ca 100644
--- a/layouts/_default/home.atom.xml
+++ b/layouts/_default/home.atom.xml
@@ -4,9 +4,10 @@
xml:lang="{{ site.LanguageCode }}">
{{ printf `<title type="html"><![CDATA[%s]]></title>` site.Title | safeHTML }}
{{ with site.Params.description }}{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}{{ end }}
- <link href="{{ "/" | absURL }}" type="text/html" />
+ <link href="{{ site.BaseURL | absURL }}" type="text/html" />
{{ with site.Home.OutputFormats.Get "ATOM" }}<link href="{{ .Permalink | absURL }}" rel="self" type="{{ .MediaType.Type | html }}" />{{ end }}
{{ with site.Home.OutputFormats.Get "FEED"}}<link href="{{ .Permalink | absURL }}" rel="alternate" type="{{ .MediaType.Type | html }}" />{{end}}
+ {{ with site.Home.OutputFormats.Get "JSON"}}<link href="{{ .Permalink | absURL }}" rel="alternate" type="{{ .MediaType.Type | html }}" />{{end}}
{{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}<icon>{{ $logo.Permalink | absURL }}</icon>
<logo>{{ $logo.Permalink | absURL }}</logo>
{{ with site.Author.name }}<author>
diff --git a/layouts/_default/home.feed.xml b/layouts/_default/home.feed.xml
index 3522efc..912070d 100644
--- a/layouts/_default/home.feed.xml
+++ b/layouts/_default/home.feed.xml
@@ -9,20 +9,21 @@
xmlns:media="http://search.yahoo.com/mrss/"
xml:lang="{{ site.LanguageCode }}">
<channel>
- {{ printf `<title type="html"><![CDATA[%s RSS]]></title>` site.Title | safeHTML }}
+ {{ printf `<title type="html"><![CDATA[%s RSS 2.0]]></title>` site.Title | safeHTML }}
</channel>
- <link type="text/html">{{ "/" | absURL }}</link>
+ <link type="text/html">{{ site.BaseURL | absURL }}</link>
{{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}
<image>
<url>{{ $logo.Permalink | absURL }}</url>
- {{ printf `<title type="html"><![CDATA[%s RSS]]></title>` site.Title | safeHTML }}
- <link>{{ "/" | absURL }}</link>
+ {{ printf `<title type="html"><![CDATA[%s RSS 2.0]]></title>` site.Title | safeHTML }}
+ <link>{{ site.BaseURL | absURL }}</link>
<width>{{ $logo.Width }}</width>
<height>{{ $logo.Height }}</height>
</image>
- <link href="{{ "/" | absURL }}" type="text/html" />
+ <link href="{{ site.BaseURL | absURL }}" type="text/html" />
{{ with site.Home.OutputFormats.Get "FEED"}}<atom:link href="{{ .Permalink | absURL }}" rel="self" type="{{ .MediaType.Type | html }}" />{{end}}
{{ with site.Home.OutputFormats.Get "ATOM"}}<atom:link href="{{ .Permalink | absURL }}" rel="alternate" type="{{ .MediaType.Type | html }}" />{{end}}
+ {{ with site.Home.OutputFormats.Get "JSON"}}<link href="{{ .Permalink | absURL }}" rel="alternate" type="{{ .MediaType.Type | html }}" />{{end}}
{{ with site.Params.description }}{{ printf `<description type="html"><![CDATA[%s]]></description>` . | safeHTML }}{{ end }}
<generator>Hugo {{ hugo.Version }}</generator>
{{ with site.Author.name }}{{ printf `<dc:creator type="html"><![CDATA[%s]]></dc:creator>` . | safeHTML }}{{ end }}
diff --git a/layouts/_default/home.json.json b/layouts/_default/home.json.json
new file mode 100644
index 0000000..77f5f4d
--- /dev/null
+++ b/layouts/_default/home.json.json
@@ -0,0 +1,26 @@
+{
+ "version": "https://jsonfeed.org/version/1.1",
+ "title": {{ (printf "%s JSON Feed" site.Title) | jsonify }},
+ "home_page_url": {{ site.BaseURL | absURL | jsonify }},
+ {{ with .OutputFormats.Get "JSON" }}"feed_url": {{.Permalink | absURL | jsonify }},{{ end }}
+ {{ with site.Params.description}}"description": {{site.Params.description | jsonify}},{{end}}
+ {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png" ) }}{{ $logo = $logo.Resize "96x96" }}
+ "icon": {{ $logo.Permalink | jsonify }},
+ "favicon": {{ $logo.Permalink | jsonify }},
+ {{ with site.Author.name }}"author":
+ {
+ "name": {{ . | jsonify }}
+ },{{ end }}
+ {{ with site.LanguageCode }}"language" : "{{ . }}",{{ end }}{{ $feedsize := site.Params.feedSize | default 25 }}
+ "items": [{{ $r := first $feedsize (where site.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections) }} {{ range $i, $ := $r }}{{ if $i }},{{ end }}
+ {
+ "id": {{ $uuid := sha1 (.Permalink | absURL)}}"{{substr $uuid 0 8}}-{{substr $uuid 8 4}}-5{{substr $uuid 13 3}}-{{substr $uuid 16 1}}9{{substr $uuid 17 2}}-{{substr $uuid 21 12}}",
+ "url": {{ .Permalink | jsonify }},
+ "title": {{ .Title | plainify | chomp | jsonify }},
+ "summary": {{ .Summary | plainify | chomp | jsonify }},
+ "date_published": {{ .PublishDate.UTC.Format site.Params.dateFormatFeed | jsonify }},
+ "date_modified" : {{ .Lastmod.UTC.Format site.Params.dateFormatFeed | jsonify }}
+ }
+ {{- end}}
+ ]
+}
diff --git a/theme.toml b/theme.toml
index 590551e..508cbf6 100644
--- a/theme.toml
+++ b/theme.toml
@@ -11,32 +11,31 @@ demosite = "https://sergeyklay.github.io/gohugo-theme-ed/"
tags = [
"blog",
- "responsive",
- "simple",
"clean",
+ "customizable",
+ "ed",
"light",
"minimal",
"minimalist",
- "customizable",
- "ed"
+ "responsive",
+ "simple"
]
# The theme's features:
features = [
"blog",
- "shortcodes",
- "responsive",
- "posts",
- "opengraph",
- "favicon",
- # "archive",
- # "search",
"clean",
- "simple",
+ "favicon",
"feed",
"minimal",
"minimalist",
- "mobile"
+ "mobile",
+ "opengraph",
+ "posts",
+ "responsive",
+ "rss",
+ "shortcodes",
+ "simple"
]
min_version = "0.95.0"