Skip to content

Commit 60420b3

Browse files
authored
VACMS-20502 Add hardcoded metadata to Policies pages (#2466)
1 parent b7b11f9 commit 60420b3

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/site/filters/liquid.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,4 +2241,23 @@ module.exports = function registerFilters() {
22412241
}
22422242
return null;
22432243
};
2244+
2245+
liquid.filters.assignHardcodedMetaDescription = url => {
2246+
if (!url) {
2247+
return null;
2248+
}
2249+
2250+
const META_DESCRIPTIONS = {
2251+
'/policies':
2252+
'Find VA policies on privacy and patient rights, family rights, visitation, and more.',
2253+
};
2254+
2255+
for (const [endOfPath, content] of Object.entries(META_DESCRIPTIONS)) {
2256+
if (url?.endsWith(endOfPath)) {
2257+
return content;
2258+
}
2259+
}
2260+
2261+
return null;
2262+
};
22442263
};

src/site/filters/liquid.unit.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,3 +3425,46 @@ describe('runAndFnConditions', () => {
34253425
expect(liquid.filters.andFn(3, ...testingParams)).to.be.false;
34263426
});
34273427
});
3428+
3429+
describe('assignHardcodedMetaDescription', () => {
3430+
it('should return the correct description when a matching path is given', () => {
3431+
expect(
3432+
liquid.filters.assignHardcodedMetaDescription(
3433+
'/minneapolis-health-care/policies',
3434+
),
3435+
).to.equal(
3436+
'Find VA policies on privacy and patient rights, family rights, visitation, and more.',
3437+
);
3438+
});
3439+
3440+
it('should return null if a matching path is not given', () => {
3441+
expect(liquid.filters.assignHardcodedMetaDescription('')).to.be.null;
3442+
});
3443+
3444+
it('should return null if a matching path is not given', () => {
3445+
expect(
3446+
liquid.filters.assignHardcodedMetaDescription('/minneapolis-health-care'),
3447+
).to.be.null;
3448+
});
3449+
3450+
it('should return null if a matching path is not given', () => {
3451+
expect(liquid.filters.assignHardcodedMetaDescription(null)).to.be.null;
3452+
});
3453+
3454+
it('should return null if a matching path is not given', () => {
3455+
expect(liquid.filters.assignHardcodedMetaDescription(undefined)).to.be.null;
3456+
});
3457+
3458+
it('should return null if a matching path is not given', () => {
3459+
expect(liquid.filters.assignHardcodedMetaDescription('/resources')).to.be
3460+
.null;
3461+
});
3462+
3463+
it('should return null if a matching path is not given', () => {
3464+
expect(
3465+
liquid.filters.assignHardcodedMetaDescription(
3466+
'/minneapolis-health-care/policies-for-something-else',
3467+
),
3468+
).to.be.null;
3469+
});
3470+
});

src/site/includes/metatags.drupal.liquid

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
<meta name="twitter:site" content="@DeptVetAffairs">
121121

122122
<!-- Derive the meta description. -->
123+
{% assign description = entityUrl.path | assignHardcodedMetaDescription %}
124+
123125
{% if fieldClinicalHealthServi %}
124126
{% assign description = fieldClinicalHealthServi.processed | strip_html %}
125127
{% elsif fieldPressReleaseBlurb %}
@@ -132,6 +134,8 @@
132134
{% 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.' %}
133135
{% endif %}
134136

137+
138+
135139
<!-- Add meta description tags. -->
136140
{% if description %}
137141
<meta content="{{ description }}" property="og:description">

0 commit comments

Comments
 (0)