UnitexGramLab/unitexgramlab-org

View on GitHub
themes/unitexgramlab/templates/feed.atom.twig

Summary

Maintainability
Test Coverage
{% set collection = collection|default(page.collection) %}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>The {{ site.title }} {{ page.title }}</title>
    <logo>{{ site.url }}/{{ site.logo }}</logo>
    <link href="{{ site.url }}{{ uri.path() }}.{{ uri.extension() }}" rel="self" />
    <subtitle>{{ collection.params.description }}</subtitle>
    <updated>{{ collection|first.date|date("Y-m-d\\TH:i:sP") }}</updated>
    <author>
      <name>{{ site.author.name }}</name>
    </author>
    <id>{{ site.url }}{{ uri.route() }}</id>
    {% for item in collection %}
    {% set banner = item.media.images|first %}
    <entry>
        <title>{{ item.title|e }}</title>
        <id>{{ site.url }}{{ item.route() }}</id>
        <updated>{{ item.modified|date("Y-m-d\\TH:i:sP") }}</updated>
        <published>{{ item.date|date("Y-m-d\\TH:i:sP") }}</published>
        <link href="{{ site.url }}{{ item.route() }}"/>
        {% for tag in item.taxonomy.tag %}
        <category term="{{ tag|lower }}" label="{{ tag|capitalize }}" />
        {% endfor %}
        {% for author in item.taxonomy.author %}
        <author>
          <name>{{ author }}</name>
        </author>
        {% endfor %}   
        <content type="html">
            <![CDATA[
            {% if banner %}
            {{ banner.cropZoom(600,400).html|raw }}
            {% endif %}
            {{ item.summary|safe_truncate_html(collection.params.length)|raw }}
            {% set readMore = '[Read More](' ~ site.url ~ item.route() ~ '?target=_blank)' %}
            {{ readMore|markdown }}
            ]]>
        </content>
    </entry>
    {% endfor %}
</feed>