Skip to content

Commit

Permalink
Add OpenGraph tags to home and detail pages
Browse files Browse the repository at this point in the history
Add OpenGraph tags (and the associated social cards) to the main
(list view) page as well as on the individual detail pages.

Closes #460
  • Loading branch information
brianlove committed Jun 25, 2024
1 parent 5940da9 commit b7c7327
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 16 deletions.
112 changes: 104 additions & 8 deletions web/gui-v2/package-lock.json

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

1 change: 1 addition & 0 deletions web/gui-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@eto/eto-ui-components": "^1.8.0",
"@eto/social-cards": "^0.4.3",
"@mdx-js/react": "^2.3.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.5",
Expand Down
25 changes: 25 additions & 0 deletions web/gui-v2/src/components/MetaTagsWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';

import { MetaTags } from '@eto/social-cards';
import socialCard from '@eto/social-cards/dist/tools/parat.png';

const MetaTagsWrapper = ({
title = "PARAT \u2013 Emerging Technology Observatory",
subtitle = undefined,
description = "ETO's tool to map high-level trends in global emerging technology research."
}) => {
const fullTitle = subtitle ? `${subtitle} \u2013 ${title}` : title;

return (
<>
<title>{fullTitle}</title>
<MetaTags
title={fullTitle}
description={description}
socialCardUrl={socialCard}
/>
</>
);
};

export default MetaTagsWrapper;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AppWrapper } from '@eto/eto-ui-components';
import DetailView from '../../components/DetailView';
import ParatUsageDisclaimer from '../../components/ParatUsageDisclaimer';
import { company_data as allCompanies } from '../../static_data/data';
import MetaTagsWrapper from '../../components/MetaTagsWrapper';

const CompanyPage = ({ data }) => {
const { cset_id: companyId, name: companyName } = data.companiesJson;
Expand Down Expand Up @@ -36,9 +37,6 @@ export const query = graphql`

export const Head = ({ pageContext }) => {
return (
<>
<html lang="en" />
<title>{pageContext.name} &ndash; PARAT &ndash; Emerging Technology Observatory</title>
</>
<MetaTagsWrapper subtitle={pageContext.name} />
);
};
6 changes: 2 additions & 4 deletions web/gui-v2/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@eto/eto-ui-components';

import ListView from '../components/ListView';
import MetaTagsWrapper from '../components/MetaTagsWrapper';
import ParatUsageDisclaimer from '../components/ParatUsageDisclaimer';

const styles = {
Expand Down Expand Up @@ -65,9 +66,6 @@ export default IndexPage;

export const Head = () => {
return (
<>
<html lang="en" />
<title>PARAT &ndash; Emerging Technology Observatory</title>
</>
<MetaTagsWrapper />
);
};

0 comments on commit b7c7327

Please sign in to comment.