Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adriancofie committed May 22, 2024
2 parents da25271 + d05995f commit 49be2f3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 11 deletions.
4 changes: 3 additions & 1 deletion cypress/e2e/PageNotFound.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ Feature: As a user, if I visit the definition page with a pretty url name that d
And the link "cancer type" to "https://www.cancer.gov/types" appears on the page
And the link "Get in touch" to "https://www.cancer.gov/contact" appears on the page
And the search bar appear below

And the page contains meta tags with the following names
| name | content |
| prerender-status-code | 404 |
4 changes: 4 additions & 0 deletions cypress/e2e/PrettyUrlRedirect.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ Feature: As the website, I should redirect CDR IDs in URLs to its counterpart pr
Given the user navigates to "/def/750633"
Then the system redirects user to "/def/acenocoumarol"
And the system appends "?redirect=true" to the URL
And the page contains meta tags with the following names
| name | content |
| prerender-status-code | 301 |
| prerender-header | Location: http://localhost:3000/def/acenocoumarol |
4 changes: 2 additions & 2 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nciocpl/drug-dictionary-app",
"version": "1.2.0",
"version": "1.3.0",
"description": "Drug Dictionary App",
"repository": {
"type": "git",
Expand Down Expand Up @@ -90,9 +90,9 @@
"coverageDirectory": "coverage/jest",
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.test.{js,jsx,ts,tsx}",
"!src/**/*.d.ts",
"!cypress/**/*.{spec,test}.{js,jsx,ts,tsx}",
"!src/**/*.test.{js,jsx,ts,tsx}",
"!src/**/*.d.ts",
"!cypress/**/*.{spec,test}.{js,jsx,ts,tsx}",
"!src/setupTests.js",
"!src/serviceWorker.js"
],
Expand Down
23 changes: 22 additions & 1 deletion src/views/Definition/Definition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,30 @@ const Definition = () => {
}
}, [queryResponse, setDrugDefinition]);

const preRenderHandler = () => {
const preRenderObj = {};

if (location.search === '?redirect=true') {
preRenderObj.statusCode = (
<meta name="prerender-status-code" content="301" />
);
preRenderObj.headerLocation = (
<meta
name="prerender-header"
content={'Location: ' + baseHost + window.location.pathname}
/>
);
}

return preRenderObj;
};

/**
* Helper function to render metadata.
*/
const renderHelmet = () => {
// Home is indexable, expand and search are not.

const preRender = preRenderHandler();
return (
<Helmet>
<title>{`Definition of ${drugDefinition.payload.name} - ${dictionaryTitle} - ${siteName}`}</title>
Expand All @@ -104,9 +122,12 @@ const Definition = () => {
})
}
/>
{preRender.statusCode}
{preRender.headerLocation}
</Helmet>
);
};

return (
<>
{drugDefinitionLoaded && drugDefinition && (
Expand Down
21 changes: 18 additions & 3 deletions src/views/ErrorBoundary/ErrorPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect } from 'react';
import { Helmet } from 'react-helmet';
import { useTracking } from 'react-tracking';

import { useStateValue } from '../../store/store';
Expand All @@ -21,10 +22,24 @@ const ErrorPage = () => {
});
}, []);

const renderHelmet = () => {
return (
<Helmet>
<title>Errors Occurred</title>
<meta property="dcterms.subject" content="Error Pages" />
<meta property="dcterms.type" content="errorpage" />
<meta name="prerender-status-code" content="500" />
</Helmet>
);
};

return (
<div className="error-container">
<h1>{i18n.errorPageText[language]}</h1>
</div>
<>
{renderHelmet()}
<div className="error-container">
<h1>{i18n.errorPageText[language]}</h1>
</div>
</>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/views/ErrorBoundary/PageNotFound.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const PageNotFound = () => {
<title>{i18n.pageNotFoundTitle[language]}</title>
<meta property="dcterms.subject" content="Error Pages" />
<meta property="dcterms.type" content="errorpage" />
<meta name="prerender-status-code" content="404" />
</Helmet>
);
};
Expand Down

0 comments on commit 49be2f3

Please sign in to comment.