Skip to content

Commit

Permalink
D8CORE-7305 Use article tags only when a header is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Nov 6, 2024
1 parent cfc9f64 commit c44f97d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{%- endif -%}
{%- endif -%}

<article {{ attributes }} class="su-card {{ modifier_class }}">
<{{ is_article or card_headline is not empty ? "article" : "div" }} {{ attributes }} class="su-card {{ modifier_class }}">
{# For variant where whole card is a link, add an <a> within the outer wrapper <div> #}
{%- if allow_links == false %}
<a href="{{ card_link }}" {{ card_cta_attributes }}>
Expand Down Expand Up @@ -125,7 +125,7 @@
{% endif %}
{% endblock block_card_media -%}

<section class="su-card__contents">
<div class="su-card__contents">
{# Card Super Headline #}
{%- block block_card_super_headline %}
{% if card_super_headline is not empty %}
Expand Down Expand Up @@ -171,8 +171,10 @@
</div>
{% endif -%}
{% endblock -%}
</section>{# end of .su-card__contents #}
</div>{# end of .su-card__contents #}

{%- if allow_links == false %}
</a>
{%- endif -%}
</article>

</{{ is_article or card_headline is not empty ? "article" : "div" }}>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
use Drupal\node\NodeInterface;
use Symfony\Component\Finder\Finder;


/**
* Implements hook_preprocess_HOOK().
*/
function stanford_basic_page_types_preprocess_pattern_card__layout__node__stanford_page(&$variables) {
$variables['is_article'] = true;
}

/**
* Implements hook_page_attachments().
*/
Expand Down
11 changes: 3 additions & 8 deletions modules/stanford_events/templates/components/list/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{%- endif -%}
{% set header_tag = variant == 'h3_header' ? 'h3' : 'h2' %}

<div {{ attributes }}>
<article {{ attributes }}>
<div class="su-event-list-item__date">
<div class="su-date-stacked su-date-stacked--no-background" aria-hidden="true">
<span class="su-event-start-month">{{ start_month }}</span>
Expand Down Expand Up @@ -146,11 +146,6 @@
{%- if location_sorting_code|render_clean is not empty %}
{{- location_sorting_code -}}
{% endif %}
</div>
{# {% endif %}#}

{# Edit this Event #}
<div class="views-field-su-event-edit">{{- edit -}}</div>

</div>
</div>
</div>
</article>
7 changes: 7 additions & 0 deletions modules/stanford_person/stanford_person.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ use Drupal\taxonomy\TermInterface;
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;

/**
* Implements hook_preprocess_HOOK().
*/
function stanford_person_preprocess_pattern_card__layout__node__stanford_person(&$variables) {
$variables['is_article'] = true;
}

/**
* Implements hook_preprocess_node().
*/
Expand Down
13 changes: 13 additions & 0 deletions modules/stanford_policy/stanford_policy.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* @file
* stanford_policy.module
*/

/**
* Implements hook_preprocess_HOOK().
*/
function stanford_policy_preprocess_pattern_card__layout__node__stanford_policy(&$variables) {
$variables['is_article'] = true;
}
7 changes: 7 additions & 0 deletions modules/stanford_publication/stanford_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ use Drupal\stanford_publication\Entity\CitationInterface;
use Drupal\views\ViewExecutable;
use Symfony\Component\Finder\Finder;

/**
* Implements hook_preprocess_HOOK().
*/
function stanford_publication_preprocess_pattern_card__layout__node__stanford_publication(&$variables) {
$variables['is_article'] = true;
}

/**
* Implements hook_library_info_build().
*/
Expand Down

0 comments on commit c44f97d

Please sign in to comment.