diff options
author | Emir Ribic <ribice@gmail.com> | 2018-09-04 00:08:42 +0300 |
---|---|---|
committer | Emir Ribic <ribice@gmail.com> | 2018-09-04 00:08:42 +0300 |
commit | 9dc53fc6f9b272155c92c93d26f7a6688c9e0c18 (patch) | |
tree | ef39b7ce860b11a2db47e40982e7f6fe58413453 | |
parent | b32f0b8f923c42fb470729b07d2dbbb29e78b061 (diff) |
Add RSS Support
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | data/theme.toml | 3 | ||||
-rw-r--r-- | exampleSite/config.toml | 6 | ||||
-rw-r--r-- | layouts/_default/index.rss.xml | 27 | ||||
-rw-r--r-- | layouts/partials/header.html | 3 | ||||
-rw-r--r-- | layouts/partials/svg/icons.html | 2 |
6 files changed, 44 insertions, 2 deletions
@@ -39,6 +39,11 @@ googleAnalytics = "" Paginate = 5 enableRobotsTXT = true +[params.rss] # Adding this tag enables RSS feed + +includeContent = true # Includes whole content in rss +authorName = "Emir Ribic" # Author full name +authorEmail = "ribice@gmail.com" # Author email [params.assets] customCSS = ["css/custom.css"] diff --git a/data/theme.toml b/data/theme.toml index e82c3e6..6dd01c0 100644 --- a/data/theme.toml +++ b/data/theme.toml @@ -6,4 +6,5 @@ github = 'https://github.com/' instagram = 'https://instagram.com/' linkedin = 'https://linkedin.com/in/' twitter = 'https://twitter.com/' -gitlab = 'https://gitlab.com/'
\ No newline at end of file +gitlab = 'https://gitlab.com/' +rss = "/"
\ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 260e549..b907972 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -13,6 +13,12 @@ enableRobotsTXT = true [params.assets] customCSS = ["css/custom.css"] +[params.rss] + +includeContent = true # Includes whole content in rss +authorName = "Emir Ribic" # Site author's full name +authorEmail = "ribice@gmail.com" + [params.info] adsense = "" # Adsense ID (ID only, without ca-pub-) enableSocial = false # Adds OpenGraph and Twitter cards diff --git a/layouts/_default/index.rss.xml b/layouts/_default/index.rss.xml new file mode 100644 index 0000000..3911b68 --- /dev/null +++ b/layouts/_default/index.rss.xml @@ -0,0 +1,27 @@ +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> + <link>{{ .Permalink }}</link> + <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description> + <generator>Hugo - gohugo.io</generator> + <language>{{ .Site.Language }}</language> + <contact>{{ $.Site.Params.rss.authorEmail }}</contact> + <copyright>{{ .Site.Copyright | safeHTML}}</copyright> + {{ with .OutputFormats.Get "RSS" }} + {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} + {{ end }} + {{ range .Pages }} + <item> + <title>{{ .Title }}</title> + <link>{{ .Permalink }}</link> + <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + <author>{{ $.Site.Params.rss.authorName }}</author> + <guid>{{ .Permalink }}</guid> + <description>{{ .Description | html }}</description> + {{ if $.Site.Params.rss.includeContent }} + <content>{{ .Content | html }}</content> + {{ end }} + </item> + {{ end }} + </channel> +</rss>
\ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 1ef15e4..fb6ebea 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -11,6 +11,9 @@ {{ if .Site.Params.Info.enableSocial }} {{- partial "social/opengraph" . -}} {{ end }} +{{ if .Site.Params.rss }} +<link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" /> +{{ end }} <link rel="stylesheet" href="{{ "css/style.css" | relURL }}"/> {{- range .Site.Params.Assets.customCSS -}} <link rel='stylesheet' href='{{ . | absURL }}'> diff --git a/layouts/partials/svg/icons.html b/layouts/partials/svg/icons.html index 9e961ea..3909f07 100644 --- a/layouts/partials/svg/icons.html +++ b/layouts/partials/svg/icons.html @@ -41,7 +41,7 @@ {{ else if eq "linkedin" . }} <path stroke-width="1.8" d="m5.839218,4.101561c0,1.211972 -0.974141,2.194011 -2.176459,2.194011s-2.176459,-0.982039 -2.176459,-2.194011c0,-1.211094 0.974141,-2.194011 2.176459,-2.194011s2.176459,0.982917 2.176459,2.194011zm0.017552,3.94922l-4.388022,0l0,14.04167l4.388022,0l0,-14.04167zm7.005038,0l-4.359939,0l0,14.04167l4.360816,0l0,-7.370999c0,-4.098413 5.291077,-4.433657 5.291077,0l0,7.370999l4.377491,0l0,-8.89101c0,-6.915523 -7.829986,-6.66365 -9.669445,-3.259423l0,-1.891237z"/> {{ else if eq "rss" . }} - <path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/> + <path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle> {{ else if eq "gitlab" . }} <path d="M22.65 14.39L12 22.13 1.35 14.39a.84.84 0 0 1-.3-.94l1.22-3.78 2.44-7.51A.42.42 0 0 1 4.82 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.49h8.1l2.44-7.51A.42.42 0 0 1 18.6 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.51L23 13.45a.84.84 0 0 1-.35.94z"></path> {{ else if eq "telegram" . }} |