File size: 2,570 Bytes
bc8bf33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{{- $url := .Get "url" }}
{{- $limit := or (.Get "limit") (.Get "pagerSize")}}
{{- $data := dict }}
{{- with resources.GetRemote $url }}
    {{- $data = . | transform.Unmarshal }}
{{- end }}
{{- with $data }}
    {{- $version := index $data "-version" }}
    {{- if not $version }}
        <p class="verbose">{{- printf "Unable to get remote resource %q" $url }}</p>
    {{- else if eq $version "2.0" }}
        {{- $siteTitle := .channel.title }}
        {{- $siteDescription := .channel.description }}
        {{- $siteLink := .channel.link }}
        {{- $siteImage := .channel.image.url }}
        {{- $siteLanguage := .channel.language }}
        {{- $buildDate := .channel.lastBuildDate }}
        {{- with .channel.item }}
        <div role="feed" aria-busy="false">
            {{- $pagerSize := or $limit 10 }}
            {{- range $index, $channelItem := . | first $pagerSize }}
                {{- $author := or .author .creator }}
                {{- $title := .title }}
                {{- $description := or .description .summary }}
                {{- $link := .link }}
                {{- $date := .pubDate }}
                {{- $category := .category }}
                {{- $type := index .enclosure "-type" }}
                {{- $url := index .enclosure "-url" }}
                {{- if $index }}<hr class="ldots" role="presentation" aria-hidden="true">{{- end }}
                <article class="feed-item">
                    <hgroup>
                        <div>
                            {{- with $author }}<span>{{ . }} </span>{{ end }}
                            {{- with $date }}<div><time datetime="{{ . }}">{{ . | truncate 19 "" }}</time></div>{{ end }}
                        </div>
                        <h1>{{ $title }}</h1>
                    </hgroup>
                    <a class="underline" href="{{ .link }}" aria-label="{{ .title }}"></a>
                    {{ $hasCover :=  or (eq $type "image/jpeg") .coverImage }}
                    <section {{ if $hasCover }}class="has-cover"{{ end }}>
                        {{- if $hasCover }}
                            {{- if .coverImage }}
                                {{- $url = .coverImage }}
                            {{- end }}
                            <img src="{{ $url }}" alt="{{ .title }}" loading="lazy" />
                        {{- end }}
                        <div class="par">{{ $description | safeHTML }}</div>
                    </section>
                </article>
            {{- end }}
        </div>
        {{- end }}
    {{- end }}
{{- end }}