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

VACMS-18659: Update clp node to be able to use url for field links #2192

Merged
merged 4 commits into from
Jul 22, 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
10 changes: 10 additions & 0 deletions src/site/filters/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2122,4 +2122,14 @@ module.exports = function registerFilters() {

return platform;
};

liquid.filters.determineFieldLink = fieldLink => {
if (!_.isEmpty(fieldLink?.url?.path)) {
return fieldLink.url.path;
}
if (!_.isEmpty(fieldLink?.uri)) {
return fieldLink.uri;
}
return null;
};
};
33 changes: 17 additions & 16 deletions src/site/layouts/campaign_landing_page.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@
width="{{ promo.entity.fieldImage.entity.thumbnail.derivative.width }}"
/>
<h3 class="vads-u-padding-x--2 vads-u-margin-top--2">
<va-link
href="{{ promo.entity.fieldPromoLink.entity.fieldLink.uri }}"
text="{{ promo.entity.fieldPromoLink.entity.fieldLink.title }}"
></va-link>
{% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink | determineFieldLink %}
{% if fieldUrl %}
<va-link active href="{{ fieldUrl }}" text="{{ promo.entity.fieldPromoLink.entity.fieldLink.title }}"></va-link>
{% endif %}
</h3>
<p class="vads-u-margin-bottom--2 vads-u-margin-top--1 vads-u-padding-x--2">
{{ promo.entity.fieldPromoLink.entity.fieldLinkSummary }}
Expand Down Expand Up @@ -206,10 +206,10 @@
<div class="vads-u-background-color--gray-light-alt vads-u-height--full medium-screen:vads-u-margin-x--1 medium-screen:vads-u-margin-y--0">
<div class="vads-u-padding--2">
<h3 class="vads-u-margin-top--0">
<va-link
href="{{ linkTeaser.entity.fieldLink.uri }}"
text="{{ linkTeaser.entity.fieldLink.title }}"
></va-link>
{% assign fieldUrl = linkTeaser.entity.fieldLink | determineFieldLink %}
{% if fieldUrl %}
<va-link active href="{{ fieldUrl }}" text="{{ linkTeaser.entity.fieldLink.title }}"></va-link>
{% endif %}
</h3>
<p class="vads-u-margin-top--1">{{ linkTeaser.entity.fieldLinkSummary }}</p>
</div>
Expand Down Expand Up @@ -248,10 +248,10 @@
{% endif %}
<div class="vads-u-margin-top--2 medium-screen:vads-u-margin-top--0">
<h3 class="vads-u-margin-top--0">
<va-link
href="{{ storyTeaser.entity.fieldLinkTeaser.entity.fieldLink.uri }}"
text="{{ storyTeaser.entity.fieldLinkTeaser.entity.fieldLink.title }}"
></va-link>
{% assign fieldUrl = storyTeaser.entity.fieldLinkTeaser.entity.fieldLink | determineFieldLink %}
{% if fieldUrl %}
<va-link active href="{{ fieldUrl }}" text="{{ storyTeaser.entity.fieldLinkTeaser.entity.fieldLink.title }}"></va-link>
{% endif %}
</h3>
<p>{{ storyTeaser.entity.fieldLinkTeaser.entity.fieldLinkSummary }}</p>
</div>
Expand Down Expand Up @@ -341,6 +341,7 @@
<!-- Title -->
<h3 class="vads-u-margin-top--0">
{% if eventReference.entity.entityUrl.path and eventReference.entity.title %}

<va-link
href="{{ eventReference.entity.entityUrl.path }}"
text="{{ eventReference.entity.title }}"
Expand Down Expand Up @@ -390,10 +391,10 @@

<!-- Event link -->
{% if eventReference.entity.fieldLink.uri and eventReference.entity.fieldEventCta %}
<va-link
href="{{ eventReference.entity.fieldLink.uri }}"
text="{{ eventReference.entity.fieldEventCta }}"
/>
{% assign fieldUrl = eventReference.entity.fieldLink| determineFieldLink %}
{% if fieldUrl %}
<va-link active href="{{ fieldUrl }}" text="{{ eventReference.entity.fieldEventCta }}"></va-link>
{% endif %}
{% endif %}

<!-- Online event link -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ const nodeCampaignLandingPage = `
... on ParagraphLinkTeaser {
fieldLink {
uri
url {
path
}
title
}
fieldLinkSummary
Expand All @@ -179,6 +182,9 @@ const nodeCampaignLandingPage = `
... on ParagraphLinkTeaser {
fieldLink {
uri
url {
path
}
title
}
fieldLinkSummary
Expand Down Expand Up @@ -257,6 +263,9 @@ const nodeCampaignLandingPage = `
fieldLink {
uri
title
url {
path
}
}
fieldLinkSummary
}
Expand Down
Loading