mirror of
https://github.com/yrzam/yrzam-hugo-theme.git
synced 2025-12-10 01:39:05 +00:00
rss
This commit is contained in:
@@ -4,12 +4,15 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<!-- prettier-ignore -->
|
||||
<title>{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ .Site.Title }}</title>
|
||||
<title>{{ if not .IsHome }}{{ .LinkTitle | humanize }} - {{ end }}{{ .Site.Title }}</title>
|
||||
{{ $opts := dict "transpiler" "libsass" "targetPath" "style.css" }}
|
||||
{{ with resources.Get "css/index.scss" | toCSS $opts | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" />
|
||||
{{ end }}
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
{{ with .OutputFormats.Get "rss" -}}
|
||||
{{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
|
||||
{{ end }}
|
||||
</head>
|
||||
<body>
|
||||
{{ block "body" . }}
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
{{- end -}}
|
||||
|
||||
{{ define "footer" }}
|
||||
<!--div class="content">
|
||||
<a href="">subscribe</a>
|
||||
</div-->
|
||||
<div class="content">
|
||||
{{ with .OutputFormats.Get "rss" -}}
|
||||
{{ printf `<a rel="%s" href="%s">subscribe</a>` .Rel .Permalink | safeHTML }}
|
||||
{{ end -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
36
layouts/_default/rss.xml
Normal file
36
layouts/_default/rss.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
{{- $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 }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ .Site.Title }}{{ if not .IsHome }}: {{ .LinkTitle | humanize }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<language>{{ site.Language.LanguageCode }}</language>{{ if site.Params.email }}
|
||||
<managingEditor>{{ site.Params.email }}</managingEditor>{{ end }}
|
||||
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
|
||||
{{ 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>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>{{ if site.Params.email }}
|
||||
<author>{{ site.Params.email }}</author>{{ end }}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
|
||||
</item>
|
||||
{{- end }}
|
||||
</channel>
|
||||
</rss>
|
||||
Reference in New Issue
Block a user