Skip to content

Commit

Permalink
VACMS-20502 Add hardcoded metadata to Policies pages (#2466)
Browse files Browse the repository at this point in the history
  • Loading branch information
randimays authored Mar 3, 2025
1 parent b7b11f9 commit 60420b3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/site/filters/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2241,4 +2241,23 @@ module.exports = function registerFilters() {
}
return null;
};

liquid.filters.assignHardcodedMetaDescription = url => {
if (!url) {
return null;
}

const META_DESCRIPTIONS = {
'/policies':
'Find VA policies on privacy and patient rights, family rights, visitation, and more.',
};

for (const [endOfPath, content] of Object.entries(META_DESCRIPTIONS)) {
if (url?.endsWith(endOfPath)) {
return content;
}
}

return null;
};
};
43 changes: 43 additions & 0 deletions src/site/filters/liquid.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3425,3 +3425,46 @@ describe('runAndFnConditions', () => {
expect(liquid.filters.andFn(3, ...testingParams)).to.be.false;
});
});

describe('assignHardcodedMetaDescription', () => {
it('should return the correct description when a matching path is given', () => {
expect(
liquid.filters.assignHardcodedMetaDescription(
'/minneapolis-health-care/policies',
),
).to.equal(
'Find VA policies on privacy and patient rights, family rights, visitation, and more.',
);
});

it('should return null if a matching path is not given', () => {
expect(liquid.filters.assignHardcodedMetaDescription('')).to.be.null;
});

it('should return null if a matching path is not given', () => {
expect(
liquid.filters.assignHardcodedMetaDescription('/minneapolis-health-care'),
).to.be.null;
});

it('should return null if a matching path is not given', () => {
expect(liquid.filters.assignHardcodedMetaDescription(null)).to.be.null;
});

it('should return null if a matching path is not given', () => {
expect(liquid.filters.assignHardcodedMetaDescription(undefined)).to.be.null;
});

it('should return null if a matching path is not given', () => {
expect(liquid.filters.assignHardcodedMetaDescription('/resources')).to.be
.null;
});

it('should return null if a matching path is not given', () => {
expect(
liquid.filters.assignHardcodedMetaDescription(
'/minneapolis-health-care/policies-for-something-else',
),
).to.be.null;
});
});
4 changes: 4 additions & 0 deletions src/site/includes/metatags.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
<meta name="twitter:site" content="@DeptVetAffairs">

<!-- Derive the meta description. -->
{% assign description = entityUrl.path | assignHardcodedMetaDescription %}

{% if fieldClinicalHealthServi %}
{% assign description = fieldClinicalHealthServi.processed | strip_html %}
{% elsif fieldPressReleaseBlurb %}
Expand All @@ -132,6 +134,8 @@
{% assign description = 'Welcome to the official website of the U.S. Department of Veterans Affairs. Discover, apply for, and manage your VA benefits and care.' %}
{% endif %}



<!-- Add meta description tags. -->
{% if description %}
<meta content="{{ description }}" property="og:description">
Expand Down

0 comments on commit 60420b3

Please sign in to comment.