Commit e313798b authored by Eugen Rochko's avatar Eugen Rochko

Add AMP version of posts and fix RSS feed

parent ce6128c2
Pipeline #858 passed with stages
in 30 seconds
......@@ -18,4 +18,8 @@ pygmentsStyle = "dracula"
weight = 2
[languages.pl]
languageName = "Polski"
weight = 3
\ No newline at end of file
weight = 3
[outputs]
home = ["HTML", "RSS"]
page = ["HTML", "AMP"]
{{ 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>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
......@@ -12,15 +13,15 @@
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range .Data.Pages }}
{{ range .Site.RegularPages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
<description>{{ .Summary | html }}</description>
</item>
{{ end }}
</channel>
</rss>
\ No newline at end of file
</rss>
<!doctype html>
<html lang="en">
<head>
{{ $.Scratch.Set "output-format" "amp" }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}">
<link rel="preload" as="script" href="https://cdn.ampproject.org/v0.js">
{{ $hero := .Page.Resources.GetMatch "hero" -}}
{{ if $hero }}{{ if not $hero.Params.resize }}{{ else }}{{ $hero := $hero.Resize "800x" }}{{ end }}<link rel="preload" href="{{ $hero.Permalink }}" as="image">{{ end }}
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<link rel="canonical" href="{{ with .OutputFormats.Get "html" -}}{{ .Permalink }}{{- end }}">
<title>{{ .Page.Title }}</title>
</head>
<body>
<h1>{{ .Page.Title }}</h1>
{{ if isset .Params "subtitle" }}<h2>{{ .Params.subtitle }}</h2>{{ end }}
{{ if $hero -}}
<amp-img src="{{ $hero.Permalink }}"
width="{{ $hero.Width }}"
height="{{ $hero.Height }}"
layout="responsive"
alt="">
</amp-img>
{{- end }}
{{ .Content }}
</body>
</html>
......@@ -6,6 +6,6 @@
<link rel='stylesheet' href='/style.css'>
<link rel='stylesheet' href='/fontawesome.css'>
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s+%s" href="%s" title="%s" />` .Rel .MediaType.Type .MediaType.Suffix .Permalink $.Site.Title | safeHTML }}
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
{{ if $.Page.Scratch.Get "output-format" -}}
{{- $original := .Page.Resources.GetMatch (printf "*%s" (.Get "src")) -}}
<amp-img src="{{ if $original }}{{ $original.Permalink }}{{ else }}{{ .Get "src" }}{{ end }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- if $original }}
width="{{ $original.Width }}"
height="{{ $original.Height }}"{{ end }}
layout="responsive">
</amp-img>
{{- else -}}
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }}
<img src="{{ .Get "src" }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
/> <!-- Closing img tag -->
{{- if .Get "link" }}</a>{{ end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
<figcaption>
{{ with (.Get "title") -}}
<h4>{{ . }}</h4>
{{- end -}}
{{- if or (.Get "caption") (.Get "attr") -}}<p>
{{- .Get "caption" | markdownify -}}
{{- with .Get "attrlink" }}
<a href="{{ . }}">
{{- end -}}
{{- .Get "attr" | markdownify -}}
{{- if .Get "attrlink" }}</a>{{ end }}</p>
{{- end }}
</figcaption>
{{- end }}
</figure>
{{- end }}
{{- $src := .Get 0 -}}
{{ if $.Page.Scratch.Get "output-format" -}}
<amp-iframe width="400" height="100"
layout="responsive"
sandbox="allow-scripts allow-same-origin"
src="{{ $src }}/embed">
</amp-iframe>
{{- else -}}
<iframe src="{{ $src }}/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400"></iframe>
<script src="{{ $src | replaceRE "^https://([^/]+).*" "https://$1/embed.js" }}" async="async"></script>
{{- end }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment