diff options
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/home.atom.xml | 3 | ||||
| -rw-r--r-- | layouts/_default/home.feed.xml | 11 | ||||
| -rw-r--r-- | layouts/_default/home.json.json | 26 |
3 files changed, 34 insertions, 6 deletions
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}} + ] +} |
