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

Add OpenGraph tags to home and detail pages #462

Merged
merged 2 commits into from
Jun 26, 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
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 hub for data on private-sector companies and their AI activities."
}) => {
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 />
);
};
Loading