Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-9739: Updating news #984

Merged
merged 13 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 56 additions & 55 deletions templates/module/helfi-news-item/node--news-item.html.twig
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
{% embed '@hdbt/content/node.html.twig' %}
{% extends '@hdbt/content/node.html.twig' %}

{% block main_content %}
{% block main_content %}

{# Lead-in text, if any #}
{{ content.field_lead_in }}
{# Lead-in text, if any #}
{{ content.field_lead_in }}

{# Page divider, normally it comes from table of contents, but news does not have that #}
<div class="page-divider"></div>
{# Page divider, normally it comes from table of contents, but news does not have that #}
<div class="page-divider"></div>

{# Created date and modified date #}
{% if published_at is not empty %}
{% if date(published_at) < date('-365days') %}
{% set tag_content %}
<span {{ alternative_language ? create_attribute(({ 'lang': lang_attributes.fallback_lang, 'dir': lang_attributes.fallback_dir })) }}>{{ 'Published over a year ago'|t({}, {'context': 'The helper text before the node published timestamp'}) }}</span>
{% endset %}
{% embed '@hdbt/misc/tag-list.twig'%}
{% block content %}
{% include '@hdbt/misc/tag.twig' with {
tag: tag_content,
color: 'alert'
}%}
{% endblock content %}
{% endembed %}
{% endif %}
<div class="content-date" {{ alternative_language ? create_attribute(({ 'lang': lang_attributes.fallback_lang, 'dir': lang_attributes.fallback_dir })) }}>
{% set html_published_at = published_at|format_date('custom', 'Y-m-d') ~ 'T' ~ published_at|format_date('custom', 'H:i') %}
<time datetime="{{ html_published_at }}" class="content-date__datetime content-date__datetime--published">
<span class="visually-hidden">{{ 'Published'|t({}, {'context': 'The helper text before the node published timestamp'}) }}</span>
{{ published_at|format_date('publication_date_format') }}
</time>

{% if modified_at is not empty %}
{% set html_modified_at = modified_at|format_date('custom', 'Y-m-d') ~ 'T' ~ modified_at|format_date('custom', 'H:i') %}
<time datetime="{{ html_modified_at }}" class="content-date__datetime content-date__datetime--updated">
{% if date(modified_at) < date('-365days') %}
{{ 'Updated over a year ago'|t({}, {'context': 'The helper text before the node changed timestamp'}) }}
{% else %}
{{ 'Updated'|t({}, {'context': 'The helper text before the node changed timestamp'}) }} {{ modified_at|format_date('publication_date_format') }}
{% endif %}
</time>
{% endif %}
</div>
{# Created date and modified date #}
{% if published_at is not empty %}
{% if date(published_at) < date('-365days') %}
{% set tag_content %}
<span {{ alternative_language ? create_attribute(({ 'lang': lang_attributes.fallback_lang, 'dir': lang_attributes.fallback_dir })) }}>{{ 'Published over a year ago'|t({}, {'context': 'The helper text before the node published timestamp'}) }}</span>
{% endset %}
{% embed '@hdbt/misc/tag-list.twig'%}
{% block content %}
{% include '@hdbt/misc/tag.twig' with {
tag: tag_content,
color: 'alert'
}%}
{% endblock content %}
{% endembed %}
{% endif %}
<div class="content-date" {{ alternative_language ? create_attribute(({ 'lang': lang_attributes.fallback_lang, 'dir': lang_attributes.fallback_dir })) }}>
{% set html_published_at = published_at|format_date('custom', 'Y-m-d') ~ 'T' ~ published_at|format_date('custom', 'H:i') %}
<time datetime="{{ html_published_at }}" class="content-date__datetime content-date__datetime--published">
<span class="visually-hidden">{{ 'Published'|t({}, {'context': 'The helper text before the node published timestamp'}) }}</span>
{{ published_at|format_date('publication_date_format') }}
</time>

{# Main image #}
{% if content.field_main_image|render %}
{% include '@hdbt/misc/image-with-caption.twig' with {
figure_class: 'main-image',
image: content.field_main_image,
image_caption: main_image_caption
} %}
{% endif %}
{# End of Main image #}
{% if modified_at is not empty %}
{% set html_modified_at = modified_at|format_date('custom', 'Y-m-d') ~ 'T' ~ modified_at|format_date('custom', 'H:i') %}
<time datetime="{{ html_modified_at }}" class="content-date__datetime content-date__datetime--updated">
{% if date(modified_at) < date('-365days') %}
{{ 'Updated over a year ago'|t({}, {'context': 'The helper text before the node changed timestamp'}) }}
{% else %}
{{ 'Updated'|t({}, {'context': 'The helper text before the node changed timestamp'}) }} {{ modified_at|format_date('publication_date_format') }}
{% endif %}
</time>
{% endif %}
</div>
{% endif %}

{# Content region #}
{% if content.field_content|render %}
{{ content.field_content }}
{% endif %}
{# Main image #}
{% if content.field_main_image|render %}
{% include '@hdbt/misc/image-with-caption.twig' with {
figure_class: 'main-image',
image: content.field_main_image,
image_caption: main_image_caption
} %}
{% endif %}
{# End of Main image #}

{# Content region #}
{% if content.field_content|render|striptags|trim is not empty %}
{{ content.field_content }}
{% endif %}

{% include '@hdbt/misc/news-footer.twig' %}
{# Content after the content region #}
{% block after_content %}{% endblock after_content %}

{% endblock main_content %}
{% include '@hdbt/misc/news-footer.twig' %}

{% endembed %}
{% endblock main_content %}