From ad0b825f7f1c5678d88477e8c9abaede708ece49 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 15 Jan 2024 15:36:50 -0300 Subject: [PATCH 01/28] Use gatsby head in blog post, taxa and landing --- site/gatsby-site/src/components/AiidHead.js | 60 +++++++++++++++++++ .../src/components/blog/PrismicBlogPost.js | 12 ---- .../src/components/doc/PrismicDocPost.js | 8 --- .../src/components/taxa/CsetTaxonomyPage.js | 5 -- .../src/components/taxa/FacetTaxonomyPage.js | 3 - site/gatsby-site/src/pages/blog/index.js | 9 ++- site/gatsby-site/src/templates/blogPost.js | 16 +++++ site/gatsby-site/src/templates/landingPage.js | 10 ++-- site/gatsby-site/src/templates/post.js | 40 +++++++++---- site/gatsby-site/src/templates/taxonomy.js | 9 +++ 10 files changed, 125 insertions(+), 47 deletions(-) create mode 100644 site/gatsby-site/src/components/AiidHead.js diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js new file mode 100644 index 0000000000..f96df36a6a --- /dev/null +++ b/site/gatsby-site/src/components/AiidHead.js @@ -0,0 +1,60 @@ +import React from 'react'; +import config from '../../config'; + +const AiidHead = ({ + children, + metaTitle = null, + metaDescription = null, + path, + metaImage = null, + metaType = 'website', +}) => { + const twitter = config.siteMetadata.twitterAccount; + + metaImage ||= config.siteMetadata.ogImage; + + const canonicalUrl = config.gatsby.siteUrl + path; + + return ( + <> + {metaTitle && {metaTitle}} + {metaTitle && } + {metaTitle && } + {metaTitle && } + {metaDescription && } + {metaDescription && } + {metaDescription && } + {metaImage && } + {metaImage && } + + {/* Provide default image even when a metaImage is supplied + * to act as a fallback in case provided one fails to load. + * Some sites also allow users to pick from the available meta images + * if multiple are available. + */} + {config.siteMetadata.ogImage && ( + + )} + {config.siteMetadata.ogImage && ( + + )} + + + + {twitter && } + {twitter && } + + {canonicalUrl && } + {canonicalUrl && } + + + {config.siteMetadata.favicon && ( + + )} + + {children} + + ); +}; + +export default AiidHead; diff --git a/site/gatsby-site/src/components/blog/PrismicBlogPost.js b/site/gatsby-site/src/components/blog/PrismicBlogPost.js index 8d1804a9f4..021585d462 100644 --- a/site/gatsby-site/src/components/blog/PrismicBlogPost.js +++ b/site/gatsby-site/src/components/blog/PrismicBlogPost.js @@ -9,21 +9,10 @@ import { Trans } from 'react-i18next'; import config from '../../../config'; import { useLayoutContext } from 'contexts/LayoutContext'; import Outline from 'components/Outline'; -import AiidHelmet from 'components/AiidHelmet'; const PrismicBlogPost = ({ post, location }) => { const metaTitle = post.data.metatitle; - const metaDescription = post.data.metaDescription; - - const postImage = post.data.image?.gatsbyImageData?.images?.fallback?.src; - - let metaImage = null; - - if (postImage) { - metaImage = `${config.gatsby.siteUrl}${postImage}`; - } - const canonicalUrl = config.gatsby.siteUrl + location.pathname; const loc = new URL(canonicalUrl); @@ -42,7 +31,6 @@ const PrismicBlogPost = ({ post, location }) => { return ( <> -
AIID Blog diff --git a/site/gatsby-site/src/components/doc/PrismicDocPost.js b/site/gatsby-site/src/components/doc/PrismicDocPost.js index f14527eac5..f2475bf791 100644 --- a/site/gatsby-site/src/components/doc/PrismicDocPost.js +++ b/site/gatsby-site/src/components/doc/PrismicDocPost.js @@ -6,7 +6,6 @@ import { Trans } from 'react-i18next'; import config from '../../../config'; import { useLayoutContext } from 'contexts/LayoutContext'; import Outline from 'components/Outline'; -import AiidHelmet from 'components/AiidHelmet'; import Leaderboards from 'components/landing/Leaderboards'; import Sponsors from 'components/landing/Sponsors'; import { RichText } from 'prismic-reactjs'; @@ -19,12 +18,6 @@ const PrismicDocPost = ({ doc, location }) => { Sponsors: , }; - const metaTitle = doc.data.metatitle; - - const metaDescription = doc.data.metadescription; - - let metaImage = null; - const canonicalUrl = config.gatsby.siteUrl + location.pathname; const loc = new URL(canonicalUrl); @@ -43,7 +36,6 @@ const PrismicDocPost = ({ doc, location }) => { return ( <> -

{doc.data.title}

diff --git a/site/gatsby-site/src/components/taxa/CsetTaxonomyPage.js b/site/gatsby-site/src/components/taxa/CsetTaxonomyPage.js index a3c5e62960..f6afe054c8 100644 --- a/site/gatsby-site/src/components/taxa/CsetTaxonomyPage.js +++ b/site/gatsby-site/src/components/taxa/CsetTaxonomyPage.js @@ -3,7 +3,6 @@ import { Trans, useTranslation } from 'react-i18next'; import { getClassificationValue } from 'utils/classifications'; -import AiidHelmet from 'components/AiidHelmet'; import { isAiHarm } from 'utils/cset'; import GroupBarChart from 'components/taxa/GroupBarChart'; @@ -33,10 +32,6 @@ export default function CsetTaxonomyPage(props) { return ( <> - - - -

{metaTitle}

diff --git a/site/gatsby-site/src/components/taxa/FacetTaxonomyPage.js b/site/gatsby-site/src/components/taxa/FacetTaxonomyPage.js index 9087e46bd0..49e28a8cf1 100644 --- a/site/gatsby-site/src/components/taxa/FacetTaxonomyPage.js +++ b/site/gatsby-site/src/components/taxa/FacetTaxonomyPage.js @@ -7,7 +7,6 @@ import BillboardJS from '@billboard.js/react'; import Link from 'components/ui/Link'; import LocationMap from 'components/visualizations/LocationMap'; import { Card, Badge, Button } from 'flowbite-react'; -import AiidHelmet from 'components/AiidHelmet'; import { getClassificationValue } from 'utils/classifications'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; @@ -37,8 +36,6 @@ export default function FacetTaxonomyPage(props) { return ( <> - -

{namespace}

diff --git a/site/gatsby-site/src/pages/blog/index.js b/site/gatsby-site/src/pages/blog/index.js index af5391e2a6..337dc1ce83 100644 --- a/site/gatsby-site/src/pages/blog/index.js +++ b/site/gatsby-site/src/pages/blog/index.js @@ -1,12 +1,11 @@ import React from 'react'; import { graphql } from 'gatsby'; import PostsListing from 'components/blog/PostsListing'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; const BlogPage = (props) => { return ( <> -

Blog

@@ -19,6 +18,12 @@ const BlogPage = (props) => { export default BlogPage; +export const Head = (props) => ( + <> + + +); + export const IndexQuery = graphql` query BlogPosts($locale: String!) { posts: allPrismicBlog( diff --git a/site/gatsby-site/src/templates/blogPost.js b/site/gatsby-site/src/templates/blogPost.js index 9071f80df9..fe7c963a82 100644 --- a/site/gatsby-site/src/templates/blogPost.js +++ b/site/gatsby-site/src/templates/blogPost.js @@ -1,6 +1,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import PrismicBlogPost from 'components/blog/PrismicBlogPost'; +import AiidHead from 'components/AiidHead'; export default function BlogPost(props) { const post = props?.data?.post; @@ -8,6 +9,21 @@ export default function BlogPost(props) { return <>{post && }; } +export const Head = (props) => { + const post = props?.data?.post; + + return ( + <> + + + ); +}; + export const pageQuery = graphql` query Post($slug: String!, $locale: String!) { site { diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index d77e1319ac..92c59f57f9 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -1,5 +1,4 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; import Featured from 'components/landing/Featured'; import Leaderboards from 'components/landing/Leaderboards'; import Blog from 'components/landing/Blog'; @@ -19,6 +18,7 @@ import CommonEntities from 'components/entities/CommonEntities'; import config from '../../config'; import sortBy from 'lodash/sortBy'; import PostPreviewNew from 'components/blog/PrismicPostPreview'; +import AiidHead from 'components/AiidHead'; const LandingPage = (props) => { const { data } = props; @@ -170,10 +170,10 @@ export function Head({ location }) { return ( <> - - {title} - - + {title} + + + ); } diff --git a/site/gatsby-site/src/templates/post.js b/site/gatsby-site/src/templates/post.js index 54269861b4..edb14d5854 100644 --- a/site/gatsby-site/src/templates/post.js +++ b/site/gatsby-site/src/templates/post.js @@ -1,5 +1,4 @@ import React, { useEffect } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; import { graphql, Link } from 'gatsby'; import { MDXProvider } from '@mdx-js/react'; import config from '../../config'; @@ -11,6 +10,7 @@ import Outline from 'components/Outline'; import DateLabel from 'components/ui/DateLabel'; import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; import { useLayoutContext } from 'contexts/LayoutContext'; +import AiidHead from 'components/AiidHead'; export default function Post(props) { const { @@ -20,16 +20,6 @@ export default function Post(props) { const metaTitle = mdx.frontmatter.metaTitle; - const metaDescription = mdx.frontmatter.metaDescription; - - const postImage = mdx.frontmatter.image?.childImageSharp?.gatsbyImageData?.images?.fallback?.src; - - let metaImage = null; - - if (postImage) { - metaImage = `${config.gatsby.siteUrl}${postImage}`; - } - const canonicalUrl = config.gatsby.siteUrl + props.location.pathname; const loc = new URL(canonicalUrl); @@ -48,7 +38,6 @@ export default function Post(props) { return ( <> -
AIID Blog @@ -87,6 +76,33 @@ export default function Post(props) { var Author = ({ name }) => {name}; +export const Head = (props) => { + const mdx = props?.data?.mdx; + + const metaTitle = mdx.frontmatter.metaTitle; + + const metaDescription = mdx.frontmatter.metaDescription; + + const postImage = mdx.frontmatter.image?.childImageSharp?.gatsbyImageData?.images?.fallback?.src; + + let metaImage = null; + + if (postImage) { + metaImage = `${config.gatsby.siteUrl}${postImage}`; + } + + return ( + <> + + + ); +}; + export const pageQuery = graphql` query PostTemplateQuery($slug: String!, $locale: String!) { site { diff --git a/site/gatsby-site/src/templates/taxonomy.js b/site/gatsby-site/src/templates/taxonomy.js index a4b47b23db..1635ed2431 100644 --- a/site/gatsby-site/src/templates/taxonomy.js +++ b/site/gatsby-site/src/templates/taxonomy.js @@ -2,6 +2,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import CsetTaxonomyPage from 'components/taxa/CsetTaxonomyPage'; import FacetTaxonomyPage from 'components/taxa/FacetTaxonomyPage'; +import AiidHead from 'components/AiidHead'; const Taxonomy = (props) => { if (!props || !props.pageContext || !props.data) { @@ -14,6 +15,14 @@ const Taxonomy = (props) => { export default Taxonomy; +export const Head = (props) => { + const { namespace } = props.pageContext.taxonomy; + + const metaTitle = `${namespace} Charts`; + + return ; +}; + export const pageQuery = graphql` query ($namespace: String!) { allMongodbAiidprodClassifications( From d9560e5d876d9590379a1c41130b558e976ea72f Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 15 Jan 2024 16:59:39 -0300 Subject: [PATCH 02/28] Add gatsby head to account --- site/gatsby-site/src/components/AiidHead.js | 2 +- site/gatsby-site/src/pages/404.js | 11 +++++++---- site/gatsby-site/src/pages/account.js | 19 ++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index f96df36a6a..98c33d116d 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -52,7 +52,7 @@ const AiidHead = ({ )} - {children} + {children && <>{children}} ); }; diff --git a/site/gatsby-site/src/pages/404.js b/site/gatsby-site/src/pages/404.js index 4488451582..7da6e858d6 100644 --- a/site/gatsby-site/src/pages/404.js +++ b/site/gatsby-site/src/pages/404.js @@ -1,12 +1,9 @@ +import AiidHead from 'components/AiidHead'; import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; const Default404 = () => { return (
- - Page not found -

Unknown page.

Please use the menus to navigate to an existing page.
@@ -15,4 +12,10 @@ const Default404 = () => { ); }; +export const Head = (props) => ( + + Page not found + +); + export default Default404; diff --git a/site/gatsby-site/src/pages/account.js b/site/gatsby-site/src/pages/account.js index 0b7d1d0bdd..d35e19d819 100644 --- a/site/gatsby-site/src/pages/account.js +++ b/site/gatsby-site/src/pages/account.js @@ -3,20 +3,15 @@ import { Spinner } from 'flowbite-react'; import { useUserContext } from '../contexts/userContext'; import { Trans, useTranslation } from 'react-i18next'; import Link from 'components/ui/Link'; -import AiidHelmet from 'components/AiidHelmet'; import UserSubscriptions from 'components/UserSubscriptions'; import UserDetails from 'components/users/UserDetails'; +import AiidHead from 'components/AiidHead'; -const Account = (props) => { +const Account = () => { const { user, loading } = useUserContext(); - const { t } = useTranslation(['account']); - return ( <> - - {t('Account Details')} -

Account Details @@ -52,4 +47,14 @@ const Account = (props) => { ); }; +export const Head = (props) => { + const { t } = useTranslation(['account']); + + return ( + + {t('Account Details')} + + ); +}; + export default Account; From 1a26b5f5e2add65ce4d169d6c70bae0b52a149f5 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 16 Jan 2024 10:03:40 -0300 Subject: [PATCH 03/28] Replace AiidHelmet in admin, classifications, discover, incidents, newsdigest and taxonomies --- .../i18n/locales/es/translation.json | 5 +++- .../i18n/locales/fr/translation.json | 5 +++- site/gatsby-site/src/pages/admin/index.js | 21 ++++++++------ site/gatsby-site/src/pages/apps/checklists.js | 26 ++++++++++------- .../src/pages/apps/classifications.js | 17 ++++++++--- site/gatsby-site/src/pages/apps/discover.js | 28 +++++++++++++++---- site/gatsby-site/src/pages/apps/incidents.js | 25 +++++++++++++---- site/gatsby-site/src/pages/apps/newsdigest.js | 23 +++++++++++---- site/gatsby-site/src/pages/taxonomies.js | 27 ++++++++++++------ 9 files changed, 128 insertions(+), 49 deletions(-) diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index f1e7baab4d..23bfa97150 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -288,5 +288,8 @@ "Incident and Issue Reports": "Incidentes e Informes de Problemas", "Issue Reports": "Informes de Problemas", "found": "encontrados", - "results found": "resultados encontrados" + "results found": "resultados encontrados", + "Artificial Intelligence Incident Database - Discover": "Base de datos de incidentes de inteligencia artificial - Descubrir", + "AIID incidents list": "Lista de incidentes de AIID", + "Find AI related incidents and reports": "Encuentra incidentes e informes relacionados con la IA" } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index 98d3bedb7b..d0005c7c7a 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -276,5 +276,8 @@ "Incident and Issue Reports": "Incidents et rapports de problèmes", "Issue Reports": "Rapports de problèmes", "found": "trouvés", - "results found": "résultats trouvés" + "results found": "résultats trouvés", + "Artificial Intelligence Incident Database - Discover": "Base de données des incidents d'intelligence artificielle - Découvrir", + "AIID incidents list": "Liste des incidents AIID", + "Find AI related incidents and reports": "Trouver des incidents et des rapports liés à l'IA" } diff --git a/site/gatsby-site/src/pages/admin/index.js b/site/gatsby-site/src/pages/admin/index.js index 9f64b3b897..5d5d649e61 100644 --- a/site/gatsby-site/src/pages/admin/index.js +++ b/site/gatsby-site/src/pages/admin/index.js @@ -1,5 +1,4 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; import { FIND_USERS } from '../../graphql/users'; import { useQuery } from '@apollo/client/react'; import UsersTable from 'components/users/UsersTable'; @@ -9,12 +8,9 @@ import { Button } from 'flowbite-react'; import { Trans } from 'react-i18next'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; import useLocalizePath from 'components/i18n/useLocalizePath'; +import AiidHead from 'components/AiidHead'; const AdminPage = (props) => { - const { - location: { pathname }, - } = props; - const { data, loading } = useQuery(FIND_USERS); const { isRole, loading: loadingAuth } = useUserContext(); @@ -25,9 +21,6 @@ const AdminPage = (props) => { return (
- - Admin -
{loading && } {!loading && !loadingAuth && !isRole('admin') &&
Not enough permissions
} @@ -46,4 +39,16 @@ const AdminPage = (props) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + return ( + + Admin + + ); +}; + export default AdminPage; diff --git a/site/gatsby-site/src/pages/apps/checklists.js b/site/gatsby-site/src/pages/apps/checklists.js index 2627bc69d7..db73ff9a67 100644 --- a/site/gatsby-site/src/pages/apps/checklists.js +++ b/site/gatsby-site/src/pages/apps/checklists.js @@ -7,29 +7,21 @@ import { graphql } from 'gatsby'; import { useQueryParams, StringParam } from 'use-query-params'; import { useQuery, useMutation } from '@apollo/client'; -import AiidHelmet from 'components/AiidHelmet'; import CheckListForm from 'components/checklists/CheckListForm'; import ChecklistsIndex from 'components/checklists/ChecklistsIndex'; import { removeTypename, checkedRiskStatus } from 'utils/checklists'; import { FIND_CHECKLIST, UPDATE_CHECKLIST } from '../../graphql/checklists'; +import AiidHead from 'components/AiidHead'; const ChecklistsPage = (props) => { - const { - location: { pathname }, - data, - } = props; + const { data } = props; const [taxa, classifications, users] = ['taxa', 'classifications', 'users'].map( (e) => data[e]?.nodes ); - const { t } = useTranslation(); - return ( <> - - {t('Risk Checklists')} - ); @@ -228,4 +220,18 @@ export const query = graphql` } `; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + return ( + + {t('Risk Checklists')} + + ); +}; + export default ChecklistsPage; diff --git a/site/gatsby-site/src/pages/apps/classifications.js b/site/gatsby-site/src/pages/apps/classifications.js index 65bb5bee8b..0bf01ea9e2 100644 --- a/site/gatsby-site/src/pages/apps/classifications.js +++ b/site/gatsby-site/src/pages/apps/classifications.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import AiidHelmet from '../../components/AiidHelmet'; import { useApolloClient } from '@apollo/client'; import gql from 'graphql-tag'; import { FIND_CLASSIFICATION } from '../../graphql/classifications'; @@ -20,6 +19,7 @@ import Table, { SelectDatePickerFilter, } from 'components/ui/Table'; import { v4 as uuidv4 } from 'uuid'; +import AiidHead from 'components/AiidHead'; const DEFAULT_EMPTY_CELL_DATA = '-'; @@ -510,9 +510,6 @@ export default function ClassificationsDbView(props) { return (
- - Artificial Intelligence Incident Database -
@@ -569,3 +566,15 @@ export default function ClassificationsDbView(props) {
); } + +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + return ( + + Artificial Intelligence Incident Database + + ); +}; diff --git a/site/gatsby-site/src/pages/apps/discover.js b/site/gatsby-site/src/pages/apps/discover.js index 492d796967..8de5820094 100644 --- a/site/gatsby-site/src/pages/apps/discover.js +++ b/site/gatsby-site/src/pages/apps/discover.js @@ -1,16 +1,34 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import Discover from 'components/discover/Discover'; +import { useTranslation } from 'react-i18next'; -function DiscoverApp(props) { +function DiscoverApp() { return (
- - Artificial Intelligence Incident Database -
); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + const metaTitle = t('Artificial Intelligence Incident Database - Discover'); + + return ( + + {metaTitle} + + ); +}; + export default DiscoverApp; diff --git a/site/gatsby-site/src/pages/apps/incidents.js b/site/gatsby-site/src/pages/apps/incidents.js index 6bbad492a6..4bbbbcea86 100644 --- a/site/gatsby-site/src/pages/apps/incidents.js +++ b/site/gatsby-site/src/pages/apps/incidents.js @@ -3,7 +3,7 @@ import IncidentsTable from '../../components/incidents/IncidentsTable'; import { FIND_INCIDENTS_TABLE } from '../../graphql/incidents'; import { useQuery } from '@apollo/client'; import { useTranslation } from 'react-i18next'; -import AiidHelmet from '../../components/AiidHelmet'; +import AiidHead from '../../components/AiidHead'; import ListSkeleton from 'elements/Skeletons/List'; import { graphql } from 'gatsby'; import { makeEntitiesHash } from 'utils/entities'; @@ -43,13 +43,8 @@ const IncidentsPage = ({ data, ...props }) => { } }, [isLiveData, incidents, data]); - const { t } = useTranslation(); - return (
- - {t('Incidents')} -
{(incidentsData && !isLiveData) || (incidentsData && isLiveData && !loading) ? (
@@ -69,6 +64,24 @@ const IncidentsPage = ({ data, ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + const metaTitle = t('Incidents'); + + const metaDescription = t('AIID incidents list'); + + return ( + + {metaTitle} + + ); +}; + export const query = graphql` query IncidentsPageQuery { incidents: allMongodbAiidprodIncidents { diff --git a/site/gatsby-site/src/pages/apps/newsdigest.js b/site/gatsby-site/src/pages/apps/newsdigest.js index c5d21290bf..cbdf3561ba 100644 --- a/site/gatsby-site/src/pages/apps/newsdigest.js +++ b/site/gatsby-site/src/pages/apps/newsdigest.js @@ -13,13 +13,13 @@ import { faTag, faBolt, } from '@fortawesome/free-solid-svg-icons'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { useUserContext } from 'contexts/userContext'; import CardSkeleton from 'elements/Skeletons/Card'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; import useLocalizePath from 'components/i18n/useLocalizePath'; -export default function NewsSearchPage(props) { +export default function NewsSearchPage() { const { t } = useTranslation(['submit']); const { isRole } = useUserContext(); @@ -162,9 +162,6 @@ export default function NewsSearchPage(props) { return ( <> - - {title} -

{title} @@ -486,3 +483,19 @@ var stats = (list) => { return [m, stdDev(list, m)]; }; + +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + const title = t('Related News Digest'); + + return ( + + {title} + + ); +}; diff --git a/site/gatsby-site/src/pages/taxonomies.js b/site/gatsby-site/src/pages/taxonomies.js index f5c6c410ce..ad7dca1b0a 100644 --- a/site/gatsby-site/src/pages/taxonomies.js +++ b/site/gatsby-site/src/pages/taxonomies.js @@ -1,25 +1,18 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; import { graphql } from 'gatsby'; import TaxonomyGraphCarousel from '../../src/components/TaxonomyGraphCarousel.js'; import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; import { Trans, useTranslation } from 'react-i18next'; import TranslationBadge from 'components/i18n/TranslationBadge'; +import AiidHead from 'components/AiidHead.js'; -export default function Taxonomies({ data, ...props }) { +export default function Taxonomies({ data }) { const { t } = useTranslation(); - const title = t('Taxonomies'); - const metaTitle = t('List of taxonomies'); - const metaDescription = t('This is the list of taxonomies supported in AIID'); - return ( <> - - {title} -

{metaTitle}

@@ -75,6 +68,22 @@ export default function Taxonomies({ data, ...props }) { ); } +export const Head = (props) => { + const { t } = useTranslation(); + + const title = t('Taxonomies'); + + const metaTitle = t('List of taxonomies'); + + const metaDescription = t('This is the list of taxonomies supported in AIID'); + + return ( + + {title} + + ); +}; + export const pageQuery = graphql` query TaxonomoyGraphCarouselTaxa { allMongodbAiidprodTaxa { From 45d8a8e2cbf468ee9ab39d4d58215bd7be3f7336 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 16 Jan 2024 11:47:25 -0300 Subject: [PATCH 04/28] Add gatsby head to reports, subit, submitted, variants, cset-chart, flagged, incidentsOverTime, leaderboard & backups --- .../{mongodbAiidprodIncidents.incident_id}.js | 20 ++++-- site/gatsby-site/src/pages/apps/reports.js | 22 ++++-- site/gatsby-site/src/pages/apps/submit.js | 21 ++++-- site/gatsby-site/src/pages/apps/submitted.js | 30 +++++--- site/gatsby-site/src/pages/apps/variants.js | 23 ++++-- site/gatsby-site/src/pages/cite/[id].js | 72 ++++++++++++------- .../src/pages/summaries/cset-charts.js | 23 ++++-- .../src/pages/summaries/flagged.js | 21 ++++-- .../src/pages/summaries/incidents.js | 25 +++++-- .../src/pages/summaries/incidentsOverTime.js | 23 ++++-- .../src/pages/summaries/leaderboard.js | 21 ++++-- site/gatsby-site/src/templates/backups.js | 21 ++++-- 12 files changed, 229 insertions(+), 93 deletions(-) diff --git a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js index a83414802d..d317f85bd4 100644 --- a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js +++ b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { useQuery } from '@apollo/client/react'; import ListSkeleton from 'elements/Skeletons/List'; import { FIND_CLASSIFICATION } from '../../../graphql/classifications'; @@ -10,7 +10,6 @@ const allNamespaces = ['CSETv1_Annotator-1', 'CSETv1_Annotator-2', 'CSETv1_Annot const ToolPage = (props) => { const { - location: { pathname }, params: { incident_id }, data: { taxa }, } = props; @@ -62,9 +61,6 @@ const ToolPage = (props) => { return (
- - CSET Tool -
{loading ? ( @@ -87,6 +83,20 @@ const ToolPage = (props) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'CSET Tool'; + + return ( + + {metaTitle} + + ); +}; + export default ToolPage; export const query = graphql` diff --git a/site/gatsby-site/src/pages/apps/reports.js b/site/gatsby-site/src/pages/apps/reports.js index 614c82f01d..a9e825c655 100644 --- a/site/gatsby-site/src/pages/apps/reports.js +++ b/site/gatsby-site/src/pages/apps/reports.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHelmet from '../../components/AiidHelmet'; +import AiidHead from '../../components/AiidHead'; import Link from '../../components/ui/Link'; import { faLink } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; @@ -207,10 +207,6 @@ export default function Incidents(props) { return (
- - Incident List - - {loading && } {!loading && (
); } + +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + const metaTitle = t('Incident List'); + + return ( + + {metaTitle} + + ); +}; diff --git a/site/gatsby-site/src/pages/apps/submit.js b/site/gatsby-site/src/pages/apps/submit.js index 99535fdbd0..9dabdd73fb 100644 --- a/site/gatsby-site/src/pages/apps/submit.js +++ b/site/gatsby-site/src/pages/apps/submit.js @@ -1,22 +1,29 @@ import React from 'react'; import SubmitForm from 'components/forms/SubmitForm'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { useTranslation } from 'react-i18next'; const SubmitPage = (props) => { + return ( +
+ +
+ ); +}; + +export const Head = (props) => { const { location: { pathname }, } = props; const { t } = useTranslation(['submit']); + const metaTitle = t('New Incident Report'); + return ( -
- - {t('New Incident Report')} - - -
+ + {metaTitle} + ); }; diff --git a/site/gatsby-site/src/pages/apps/submitted.js b/site/gatsby-site/src/pages/apps/submitted.js index 77ca81d756..cd66fdcb67 100644 --- a/site/gatsby-site/src/pages/apps/submitted.js +++ b/site/gatsby-site/src/pages/apps/submitted.js @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import AiidHelmet from '../../components/AiidHelmet'; +import AiidHead from '../../components/AiidHead'; import { ObjectId } from 'bson'; import { useMutation, useQuery } from '@apollo/client'; import { DELETE_QUICKADD, FIND_QUICKADD } from '../../graphql/quickadd.js'; @@ -12,7 +12,7 @@ import { Badge, Button, ListGroup } from 'flowbite-react'; import { useQueryParam } from 'use-query-params'; import SubmissionEdit from 'components/submissions/SubmissionEdit'; -const SubmittedIncidentsPage = ({ ...props }) => { +const SubmittedIncidentsPage = () => { const [id] = useQueryParam('editSubmission'); const [pageLoading, setPageLoading] = useState(true); @@ -90,14 +90,6 @@ const SubmittedIncidentsPage = ({ ...props }) => { return ( <> - - {id ? ( - {t('Edit submission')} - ) : ( - {t('Submitted Incident Report List')} - )} - - {pageLoading ? ( ) : ( @@ -191,4 +183,22 @@ const SubmittedIncidentsPage = ({ ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(['submitted']); + + const [id] = useQueryParam('editSubmission'); + + const metaTitle = id ? t('Edit submission') : t('Submitted Incident Report List'); + + return ( + + {metaTitle} + + ); +}; + export default SubmittedIncidentsPage; diff --git a/site/gatsby-site/src/pages/apps/variants.js b/site/gatsby-site/src/pages/apps/variants.js index 91c63ca7d3..7846a79d88 100644 --- a/site/gatsby-site/src/pages/apps/variants.js +++ b/site/gatsby-site/src/pages/apps/variants.js @@ -5,7 +5,7 @@ import { Spinner } from 'flowbite-react'; import VariantsTable from '../../components/variants/VariantsTable'; import { FIND_VARIANTS } from '../../graphql/variants'; import { FIND_INCIDENTS } from '../../graphql/incidents'; -import AiidHelmet from '../../components/AiidHelmet'; +import AiidHead from '../../components/AiidHead'; import ListSkeleton from 'elements/Skeletons/List'; import { getVariantStatus, isCompleteReport } from '../../utils/variants'; @@ -64,17 +64,12 @@ export default function IncidentsPage(props) { } }, [variantsData]); - const { t } = useTranslation(['variants']); - const setLoading = (loading) => { setIsLoading(loading); }; return (
- - {t('Variants')} -
{isLoading && (
@@ -97,3 +92,19 @@ export default function IncidentsPage(props) {
); } + +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(['variants']); + + const metaTitle = t('Variants'); + + return ( + + {metaTitle} + + ); +}; diff --git a/site/gatsby-site/src/pages/cite/[id].js b/site/gatsby-site/src/pages/cite/[id].js index d2a2378bc7..47e766731e 100644 --- a/site/gatsby-site/src/pages/cite/[id].js +++ b/site/gatsby-site/src/pages/cite/[id].js @@ -4,7 +4,7 @@ import { CloudinaryImage } from '@cloudinary/base'; import { Trans } from 'react-i18next'; import { useQuery } from '@apollo/client'; import { graphql } from 'gatsby'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { sortIncidentsByDatePublished } from 'utils/cite'; import config from '../../../config'; import { isCompleteReport } from 'utils/variants'; @@ -25,14 +25,6 @@ function CiteDynamicPage(props) { const [incident, setIncident] = useState(null); - // meta tags - - const [metaTitle, setMetaTitle] = useState(null); - - const [metaDescription, setMetaDescription] = useState(null); - - const [metaImage, setMetaImage] = useState(null); - const { data: incidentData, loading } = useQuery(FIND_FULL_INCIDENT, { variables: { query: { incident_id } }, }); @@ -41,29 +33,12 @@ function CiteDynamicPage(props) { if (incidentData?.incident) { const incidentTemp = { ...incidentData.incident }; - const sortedIncidentReports = sortIncidentsByDatePublished(incidentTemp.reports); - - const sortedReports = sortedIncidentReports.filter((report) => isCompleteReport(report)); - - const publicID = sortedReports.find((report) => report.cloudinary_id)?.cloudinary_id; - - const image = new CloudinaryImage(publicID, { - cloudName: config.cloudinary.cloudName, - }); - - setMetaTitle(`Incident ${incidentTemp.incident_id}: ${incidentTemp.title}`); - setMetaDescription(incidentTemp.description); - setMetaImage(image.createCloudinaryURL()); setIncident(incidentTemp); } }, [incidentData]); return (
- - - - {loading ? ( ) : !loading && incident ? ( @@ -84,6 +59,51 @@ function CiteDynamicPage(props) { ); } +export const Head = (props) => { + const { + location: { pathname }, + params: { id: incident_id }, + } = props; + + // meta tags + + const [metaTitle, setMetaTitle] = useState(null); + + const [metaDescription, setMetaDescription] = useState(null); + + const [metaImage, setMetaImage] = useState(null); + + const { data: incidentData } = useQuery(FIND_FULL_INCIDENT, { + variables: { query: { incident_id } }, + }); + + useEffect(() => { + if (incidentData?.incident) { + const incidentTemp = { ...incidentData.incident }; + + const sortedIncidentReports = sortIncidentsByDatePublished(incidentTemp.reports); + + const sortedReports = sortedIncidentReports.filter((report) => isCompleteReport(report)); + + const publicID = sortedReports.find((report) => report.cloudinary_id)?.cloudinary_id; + + const image = new CloudinaryImage(publicID, { + cloudName: config.cloudinary.cloudName, + }); + + setMetaTitle(`Incident ${incidentTemp.incident_id}: ${incidentTemp.title}`); + setMetaDescription(incidentTemp.description); + setMetaImage(image.createCloudinaryURL()); + } + }, [incidentData]); + + return ( + + + + ); +}; + export const query = graphql` query CitationPageQuery { allMongodbAiidprodTaxa { diff --git a/site/gatsby-site/src/pages/summaries/cset-charts.js b/site/gatsby-site/src/pages/summaries/cset-charts.js index 35c9d2bff7..2bb57279b0 100644 --- a/site/gatsby-site/src/pages/summaries/cset-charts.js +++ b/site/gatsby-site/src/pages/summaries/cset-charts.js @@ -1,12 +1,12 @@ import React from 'react'; import { graphql } from 'gatsby'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { getClassificationValue } from 'utils/classifications'; import { isAiHarm } from 'utils/cset'; import GroupBarChart from 'components/taxa/GroupBarChart'; -export default function CsetChartsPage({ data, ...props }) { +export default function CsetChartsPage({ data }) { const metaTitle = 'CSET Charts'; const allVsHarmDefinition = { @@ -24,10 +24,6 @@ export default function CsetChartsPage({ data, ...props }) { return ( <> - - - -

{metaTitle}

@@ -109,6 +105,21 @@ export default function CsetChartsPage({ data, ...props }) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'CSET Charts'; + + return ( + + {metaTitle} + + + ); +}; + export const pageQuery = graphql` query Classifications { allMongodbAiidprodClassifications(limit: 9999999) { diff --git a/site/gatsby-site/src/pages/summaries/flagged.js b/site/gatsby-site/src/pages/summaries/flagged.js index b87360f82f..e1a12cc96a 100644 --- a/site/gatsby-site/src/pages/summaries/flagged.js +++ b/site/gatsby-site/src/pages/summaries/flagged.js @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { graphql } from 'gatsby'; const ReportList = ({ report }) => ( @@ -37,14 +37,11 @@ const IncidentList = ({ incidents }) => { ); }; -export default function FlaggedIncidents({ data, ...props }) { +export default function FlaggedIncidents({ data }) { const incidents = data.allMongodbAiidprodIncidents.nodes; return ( <> - - Incident List -

Flagged Incident List

@@ -59,6 +56,20 @@ export default function FlaggedIncidents({ data, ...props }) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'Incident List'; + + return ( + + {metaTitle} + + ); +}; + export const pageQuery = graphql` query AllFlaggedIncidents { allMongodbAiidprodIncidents( diff --git a/site/gatsby-site/src/pages/summaries/incidents.js b/site/gatsby-site/src/pages/summaries/incidents.js index 2b991a8b4b..1cea8c9069 100644 --- a/site/gatsby-site/src/pages/summaries/incidents.js +++ b/site/gatsby-site/src/pages/summaries/incidents.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { graphql } from 'gatsby'; import Link from 'components/ui/Link'; import { hasVariantData } from 'utils/variants'; @@ -50,15 +50,13 @@ const IncidentList = ({ incidents }) => { ); }; -export default function Incidents({ data, ...props }) { +export default function Incidents({ data }) { const [sortOrder, setSortOrder] = useState(SORT_ORDER.DESC); // Descending order by default const [sortedIncidents, setSortedIncidents] = useState([]); const [isLoading, setIsLoading] = useState(true); - const { t } = useTranslation('incidents'); - useEffect(() => { setIsLoading(true); const incidents = [...data.allMongodbAiidprodIncidents.nodes]; @@ -77,9 +75,6 @@ export default function Incidents({ data, ...props }) { return ( <> - - {t('Incident List', { ns: 'incidents' })} -

Incident List @@ -126,6 +121,22 @@ export default function Incidents({ data, ...props }) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation('incidents'); + + const metaTitle = t('Incident List', { ns: 'incidents' }); + + return ( + + {metaTitle} + + ); +}; + export const pageQuery = graphql` query AllIncidentsPart { allMongodbAiidprodIncidents { diff --git a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js index 95455a57d0..62c3f9242a 100644 --- a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js +++ b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import MultiLineChart from 'components/visualizations/MultiLineChart'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { graphql } from 'gatsby'; import { TextInput, Label } from 'flowbite-react'; import { format } from 'date-fns'; @@ -24,7 +24,7 @@ const countByDate = (items, series, startDate) => return points.concat([newPoint]); }, []); -export default function IncidentsOverTimePage({ data, ...props }) { +export default function IncidentsOverTimePage({ data }) { const metaTitle = 'Incidents Over Time'; const [startDate, setStartDate] = useState(new Date(2020, 10, 7)); @@ -68,10 +68,6 @@ export default function IncidentsOverTimePage({ data, ...props }) { return ( <> - - - -

{metaTitle}

@@ -119,6 +115,21 @@ export default function IncidentsOverTimePage({ data, ...props }) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'Incidents Over Time'; + + return ( + + {metaTitle} + + + ); +}; + export const pageQuery = graphql` query IncidentsOverTime { allMongodbAiidprodIncidents(sort: { reports: { date_submitted: ASC } }) { diff --git a/site/gatsby-site/src/pages/summaries/leaderboard.js b/site/gatsby-site/src/pages/summaries/leaderboard.js index 2181712cbb..bfe339e944 100644 --- a/site/gatsby-site/src/pages/summaries/leaderboard.js +++ b/site/gatsby-site/src/pages/summaries/leaderboard.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import Link from 'components/ui/Link'; import SubmittersLeaderboard from 'components/leaderboards/SubmittersLeaderboard'; @@ -9,12 +9,9 @@ import OriginalSubmittersLeaderboard from 'components/leaderboards/OriginalSubmi import UniqueSubmittersLeaderboard from 'components/leaderboards/UniqueSubmittersLeaderboard'; import { Trans } from 'react-i18next'; -export default function Authors(props) { +export default function Authors() { return ( <> - - Submissions Leaderboard -

Leaderboard

@@ -37,3 +34,17 @@ export default function Authors(props) { ); } + +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'Submissions Leaderboard'; + + return ( + + {metaTitle} + + ); +}; diff --git a/site/gatsby-site/src/templates/backups.js b/site/gatsby-site/src/templates/backups.js index 1839193505..6a9fa613cd 100644 --- a/site/gatsby-site/src/templates/backups.js +++ b/site/gatsby-site/src/templates/backups.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import Link from 'components/ui/Link'; import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; import Container from 'elements/Container'; @@ -8,7 +8,7 @@ import Col from 'elements/Col'; import { format } from 'date-fns'; import config from '../../config'; -const Backups = ({ pageContext, ...props }) => { +const Backups = ({ pageContext }) => { const { backups } = pageContext; if (!backups) { @@ -42,9 +42,6 @@ const Backups = ({ pageContext, ...props }) => { return ( <> - - Database Backups and Snapshots -

Database Snapshots

@@ -108,4 +105,18 @@ const Backups = ({ pageContext, ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'Database Backups and Snapshots'; + + return ( + + {metaTitle} + + ); +}; + export default Backups; From d8610ee844aa607475ed7493a3aafda0031260fe Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 16 Jan 2024 12:22:36 -0300 Subject: [PATCH 05/28] Use gatsby head for cite-duplicate, cite, doc, entities, entity, report, tsneVisualizationPage and wordcounts --- site/gatsby-site/src/components/AiidHelmet.js | 61 ------------------ .../src/templates/cite-duplicate.js | 29 ++++++--- site/gatsby-site/src/templates/cite.js | 64 ++++++++++++++----- site/gatsby-site/src/templates/doc.js | 25 ++++++-- site/gatsby-site/src/templates/entities.js | 30 ++++++--- site/gatsby-site/src/templates/entity.js | 18 +++++- site/gatsby-site/src/templates/report.js | 36 +++++++---- .../src/templates/tsneVisualizationPage.js | 29 ++++++--- site/gatsby-site/src/templates/wordcounts.js | 21 ++++-- 9 files changed, 185 insertions(+), 128 deletions(-) delete mode 100644 site/gatsby-site/src/components/AiidHelmet.js diff --git a/site/gatsby-site/src/components/AiidHelmet.js b/site/gatsby-site/src/components/AiidHelmet.js deleted file mode 100644 index c8c4f2111c..0000000000 --- a/site/gatsby-site/src/components/AiidHelmet.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import Helmet from 'react-helmet'; -import config from '../../config'; - -const AiidHelmet = ({ - children, - metaTitle = null, - metaDescription = null, - path, - metaImage = null, - metaType = 'website', -}) => { - const twitter = config.siteMetadata.twitterAccount; - - metaImage ||= config.siteMetadata.ogImage; - - const canonicalUrl = config.gatsby.siteUrl + path; - - return ( - - {metaTitle && {metaTitle}} - {metaTitle && } - {metaTitle && } - {metaTitle && } - {metaDescription && } - {metaDescription && } - {metaDescription && } - {metaImage && } - {metaImage && } - - {/* Provide default image even when a metaImage is supplied - * to act as a fallback in case provided one fails to load. - * Some sites also allow users to pick from the available meta images - * if multiple are available. - */} - {config.siteMetadata.ogImage && ( - - )} - {config.siteMetadata.ogImage && ( - - )} - - - - {twitter && } - {twitter && } - - {canonicalUrl && } - {canonicalUrl && } - - - {config.siteMetadata.favicon && ( - - )} - - {children} - - ); -}; - -export default AiidHelmet; diff --git a/site/gatsby-site/src/templates/cite-duplicate.js b/site/gatsby-site/src/templates/cite-duplicate.js index f9285a59c8..5b5d90e74e 100644 --- a/site/gatsby-site/src/templates/cite-duplicate.js +++ b/site/gatsby-site/src/templates/cite-duplicate.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import Link from 'components/ui/Link'; @@ -9,17 +9,10 @@ import Container from 'elements/Container'; const IncidentCite = ({ pageContext }) => { const { true_incident_number, duplicate_incident_number } = pageContext; - // meta tags - - const metaTitle = 'Incident ' + true_incident_number; - const metaDescription = 'Citation record for Incident ' + duplicate_incident_number; - const canonicalUrl = getCanonicalUrl(true_incident_number); - return ( <> -

{metaDescription}

@@ -35,4 +28,24 @@ const IncidentCite = ({ pageContext }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { true_incident_number, duplicate_incident_number } = props.pageContext; + + const metaTitle = 'Incident ' + true_incident_number; + + const metaDescription = 'Citation record for Incident ' + duplicate_incident_number; + + const canonicalUrl = getCanonicalUrl(true_incident_number); + + return ( + + {metaTitle} + + ); +}; + export default IncidentCite; diff --git a/site/gatsby-site/src/templates/cite.js b/site/gatsby-site/src/templates/cite.js index 729a441b12..095b9e6c7c 100644 --- a/site/gatsby-site/src/templates/cite.js +++ b/site/gatsby-site/src/templates/cite.js @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { CloudinaryImage } from '@cloudinary/base'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; import { graphql } from 'gatsby'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { getTranslatedReports, sortIncidentsByDatePublished } from 'utils/cite'; import { computeEntities, RESPONSE_TAG } from 'utils/entities'; import config from '../../config'; @@ -40,8 +40,6 @@ function CitePage(props) { const metaTitle = `Incident ${incident.incident_id}: ${incident.title}`; - const metaDescription = incident.description; - const incidentReports = getTranslatedReports({ allMongodbAiidprodReports, translations: { @@ -56,14 +54,6 @@ function CitePage(props) { const sortedReports = sortedIncidentReports.filter((report) => isCompleteReport(report)); - const publicID = sortedReports.find((report) => report.cloudinary_id)?.cloudinary_id; - - const image = new CloudinaryImage(publicID, { - cloudName: config.cloudinary.cloudName, - }); - - const metaImage = image.createCloudinaryURL(); - const timeline = sortedReports.map( ({ date_published, title, mongodb_id, report_number, tags }) => ({ date_published, @@ -91,10 +81,6 @@ function CitePage(props) { return (
- - - - {isLiveData ? ( { + const { + location: { pathname }, + data: { + allMongodbAiidprodReports, + allMongodbTranslationsReportsEs, + allMongodbTranslationsReportsEn, + allMongodbTranslationsReportsFr, + incident, + }, + } = props; + + const { locale } = useLocalization(); + + const metaTitle = `Incident ${incident.incident_id}: ${incident.title}`; + + const metaDescription = incident.description; + + const incidentReports = getTranslatedReports({ + allMongodbAiidprodReports, + translations: { + en: allMongodbTranslationsReportsEn, + es: allMongodbTranslationsReportsEs, + fr: allMongodbTranslationsReportsFr, + }, + locale, + }); + + const sortedIncidentReports = sortIncidentsByDatePublished(incidentReports); + + const sortedReports = sortedIncidentReports.filter((report) => isCompleteReport(report)); + + const publicID = sortedReports.find((report) => report.cloudinary_id)?.cloudinary_id; + + const image = new CloudinaryImage(publicID, { + cloudName: config.cloudinary.cloudName, + }); + + const metaImage = image.createCloudinaryURL(); + + return ( + + {metaTitle} + + + ); +}; + export const query = graphql` query CitationPageQuery( $incident_id: Int diff --git a/site/gatsby-site/src/templates/doc.js b/site/gatsby-site/src/templates/doc.js index 410a6aed30..f08c2a25c3 100644 --- a/site/gatsby-site/src/templates/doc.js +++ b/site/gatsby-site/src/templates/doc.js @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { graphql, Link } from 'gatsby'; import { MDXProvider } from '@mdx-js/react'; import Components from 'components/ui/MdxComponents'; @@ -14,11 +14,6 @@ export default function Doc(props) { children, } = props; - // meta tags - const metaTitle = mdx.frontmatter.metaTitle; - - const metaDescription = mdx.frontmatter.metaDescription; - const rightSidebar = ( <> @@ -33,7 +28,6 @@ export default function Doc(props) { return ( <> -

{mdx.fields.title}

{mdx.frontmatter.aiTranslated && ( @@ -52,6 +46,23 @@ export default function Doc(props) { ); } +export const Head = (props) => { + const { + location: { pathname }, + data: { mdx }, + } = props; + + const metaTitle = mdx.frontmatter.metaTitle; + + const metaDescription = mdx.frontmatter.metaDescription; + + return ( + + {metaTitle} + + ); +}; + export const pageQuery = graphql` query DocsTemplateQuery($slug: String!, $locale: String!) { site { diff --git a/site/gatsby-site/src/templates/entities.js b/site/gatsby-site/src/templates/entities.js index 4ee451be79..f0409e9b0d 100644 --- a/site/gatsby-site/src/templates/entities.js +++ b/site/gatsby-site/src/templates/entities.js @@ -3,7 +3,7 @@ import { graphql } from 'gatsby'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { makeEntitiesHash, makeIncidentsHash } from 'utils/entities'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; const incidentFields = [ 'incidentsAsBoth', @@ -52,14 +52,6 @@ const EntitiesPage = ({ pageContext, data, ...props }) => { return (
-

{t(metaTitle)}

@@ -70,6 +62,26 @@ const EntitiesPage = ({ pageContext, data, ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(['entities']); + + const metaTitle = t('Entities'); + + const metaDescription = t('Entities involved in AI Incidents'); + + const canonicalUrl = 'https://incidentdatabase.ai/entities'; + + return ( + + {metaTitle} + + ); +}; + export const query = graphql` query EntitiesPageQuery { incidents: allMongodbAiidprodIncidents { diff --git a/site/gatsby-site/src/templates/entity.js b/site/gatsby-site/src/templates/entity.js index ae93fd34ce..eb49030603 100644 --- a/site/gatsby-site/src/templates/entity.js +++ b/site/gatsby-site/src/templates/entity.js @@ -8,7 +8,7 @@ import useToastContext, { SEVERITY } from '../hooks/useToast'; import React, { useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { computeEntities, makeEntitiesHash, makeIncidentsHash } from 'utils/entities'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import useLocalizePath from 'components/i18n/useLocalizePath'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faEnvelope } from '@fortawesome/free-solid-svg-icons'; @@ -211,7 +211,6 @@ const EntityPage = ({ pageContext, data, ...props }) => { return ( <> -
Entities @@ -289,6 +288,21 @@ const EntityPage = ({ pageContext, data, ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + pageContext: { name }, + } = props; + + const metaTitle = 'Entity: ' + name; + + return ( + + {metaTitle} + + ); +}; + function UnsubscribeButton({ children, unsubscribeToEntity, diff --git a/site/gatsby-site/src/templates/report.js b/site/gatsby-site/src/templates/report.js index d5de7e4986..6606066fae 100644 --- a/site/gatsby-site/src/templates/report.js +++ b/site/gatsby-site/src/templates/report.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import { Trans, useTranslation } from 'react-i18next'; import Container from '../elements/Container'; import SocialShareButtons from '../components/ui/SocialShareButtons'; @@ -52,17 +52,6 @@ function ReportPage(props) { return ( <> - - - -

{locale == 'en' ? metaTitle : defaultTitle}

{ + const { + location: { pathname }, + data: { report }, + } = props; + + const metaTitle = `Report ${report.report_number}`; + + return ( + + {metaTitle} + + + ); +}; + export const query = graphql` query ReportPageQuery( $report_number: Int diff --git a/site/gatsby-site/src/templates/tsneVisualizationPage.js b/site/gatsby-site/src/templates/tsneVisualizationPage.js index eae6685532..5a555c622b 100644 --- a/site/gatsby-site/src/templates/tsneVisualizationPage.js +++ b/site/gatsby-site/src/templates/tsneVisualizationPage.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import TsneVisualization from 'components/cite/TsneVisualization'; import { Trans, useTranslation } from 'react-i18next'; import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; @@ -15,18 +15,10 @@ function TsneVisulizationPage(props) { const csetClassifications = props.pageContext.csetClassifications; - // meta tags - - const metaTitle = t('Spatial Visualization'); - const metaDescription = t('Spatial Visualization'); return (
- - - -

{t(metaDescription)}

@@ -62,4 +54,23 @@ function TsneVisulizationPage(props) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const { t } = useTranslation(); + + const metaTitle = t('Spatial Visualization'); + + const metaDescription = t('Spatial Visualization'); + + return ( + + {metaTitle} + + + ); +}; + export default TsneVisulizationPage; diff --git a/site/gatsby-site/src/templates/wordcounts.js b/site/gatsby-site/src/templates/wordcounts.js index 87af627f0e..67e2f76e9d 100644 --- a/site/gatsby-site/src/templates/wordcounts.js +++ b/site/gatsby-site/src/templates/wordcounts.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHelmet from 'components/AiidHelmet'; +import AiidHead from 'components/AiidHead'; import ReactWordcloud from 'react-d3-cloud'; import Link from 'components/ui/Link'; @@ -27,14 +27,11 @@ const WordCloudCell = ({ wordCountsSorted, wordCloud }) => { ); }; -const WordCounts = ({ pageContext, ...props }) => { +const WordCounts = ({ pageContext }) => { const { wordClouds, wordCountsSorted, wordsPerCloud } = pageContext; return ( <> - - Word Counts -

Word Counts

@@ -75,4 +72,18 @@ const WordCounts = ({ pageContext, ...props }) => { ); }; +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const metaTitle = 'Word Counts'; + + return ( + + {metaTitle} + + ); +}; + export default WordCounts; From 13c12de80e5673e508ce3f4bfa258a11e25c2367 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 17 Jan 2024 09:32:30 -0300 Subject: [PATCH 06/28] Remove Head from /[id].js file --- site/gatsby-site/src/pages/cite/[id].js | 50 ------------------------- 1 file changed, 50 deletions(-) diff --git a/site/gatsby-site/src/pages/cite/[id].js b/site/gatsby-site/src/pages/cite/[id].js index 47e766731e..d1d06da5a5 100644 --- a/site/gatsby-site/src/pages/cite/[id].js +++ b/site/gatsby-site/src/pages/cite/[id].js @@ -1,13 +1,8 @@ import React, { useEffect, useState } from 'react'; import { Spinner } from 'flowbite-react'; -import { CloudinaryImage } from '@cloudinary/base'; import { Trans } from 'react-i18next'; import { useQuery } from '@apollo/client'; import { graphql } from 'gatsby'; -import AiidHead from 'components/AiidHead'; -import { sortIncidentsByDatePublished } from 'utils/cite'; -import config from '../../../config'; -import { isCompleteReport } from 'utils/variants'; import { FIND_FULL_INCIDENT } from '../../graphql/incidents'; import CiteDynamicTemplate from 'templates/citeDynamicTemplate'; @@ -59,51 +54,6 @@ function CiteDynamicPage(props) { ); } -export const Head = (props) => { - const { - location: { pathname }, - params: { id: incident_id }, - } = props; - - // meta tags - - const [metaTitle, setMetaTitle] = useState(null); - - const [metaDescription, setMetaDescription] = useState(null); - - const [metaImage, setMetaImage] = useState(null); - - const { data: incidentData } = useQuery(FIND_FULL_INCIDENT, { - variables: { query: { incident_id } }, - }); - - useEffect(() => { - if (incidentData?.incident) { - const incidentTemp = { ...incidentData.incident }; - - const sortedIncidentReports = sortIncidentsByDatePublished(incidentTemp.reports); - - const sortedReports = sortedIncidentReports.filter((report) => isCompleteReport(report)); - - const publicID = sortedReports.find((report) => report.cloudinary_id)?.cloudinary_id; - - const image = new CloudinaryImage(publicID, { - cloudName: config.cloudinary.cloudName, - }); - - setMetaTitle(`Incident ${incidentTemp.incident_id}: ${incidentTemp.title}`); - setMetaDescription(incidentTemp.description); - setMetaImage(image.createCloudinaryURL()); - } - }, [incidentData]); - - return ( - - - - ); -}; - export const query = graphql` query CitationPageQuery { allMongodbAiidprodTaxa { From 10bb384598e2221887d45d4fec8d851482c948c1 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 17 Jan 2024 16:47:47 -0300 Subject: [PATCH 07/28] Fix submitted and cite pages, and fix submit.cy tests --- .../gatsby-site/cypress/e2e/integration/submit.cy.js | 12 ++++++------ site/gatsby-site/src/pages/apps/submitted.js | 6 +----- site/gatsby-site/src/templates/cite.js | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/submit.cy.js b/site/gatsby-site/cypress/e2e/integration/submit.cy.js index de216e4577..d36a27ca00 100644 --- a/site/gatsby-site/cypress/e2e/integration/submit.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/submit.cy.js @@ -984,7 +984,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep1) { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); } cy.setEditorText( @@ -1333,7 +1333,7 @@ describe('The Submit form', () => { }; for (const key in values) { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); } cy.setEditorText( @@ -1390,7 +1390,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep1) { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); } cy.clickOutside(); @@ -1451,7 +1451,7 @@ describe('The Submit form', () => { cy.get(`[role="option"]`).first().click(); } else { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); } } @@ -1472,7 +1472,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep2) { - cy.get(`[name="${key}"]`).type(valuesStep2[key]); + cy.get(`input[name="${key}"]`).type(valuesStep2[key]); } cy.get('[data-cy="to-step-3"]').click(); @@ -1667,7 +1667,7 @@ describe('The Submit form', () => { cy.get(`[role="option"]`).first().click(); } else { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); } } diff --git a/site/gatsby-site/src/pages/apps/submitted.js b/site/gatsby-site/src/pages/apps/submitted.js index cd66fdcb67..120a322a08 100644 --- a/site/gatsby-site/src/pages/apps/submitted.js +++ b/site/gatsby-site/src/pages/apps/submitted.js @@ -188,11 +188,7 @@ export const Head = (props) => { location: { pathname }, } = props; - const { t } = useTranslation(['submitted']); - - const [id] = useQueryParam('editSubmission'); - - const metaTitle = id ? t('Edit submission') : t('Submitted Incident Report List'); + const metaTitle = 'Submissions'; return ( diff --git a/site/gatsby-site/src/templates/cite.js b/site/gatsby-site/src/templates/cite.js index 095b9e6c7c..ad0003b0ca 100644 --- a/site/gatsby-site/src/templates/cite.js +++ b/site/gatsby-site/src/templates/cite.js @@ -118,7 +118,7 @@ function CitePage(props) { export const Head = (props) => { const { - location: { pathname }, + location: { pathname: path }, data: { allMongodbAiidprodReports, allMongodbTranslationsReportsEs, @@ -157,7 +157,7 @@ export const Head = (props) => { const metaImage = image.createCloudinaryURL(); return ( - + {metaTitle} From 3b5c7bac6db3dbf604636bf34025470fd4544c8b Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 18 Jan 2024 11:21:38 -0300 Subject: [PATCH 08/28] Add gatsby head to prismic docs --- site/gatsby-site/src/templates/prismicDoc.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/site/gatsby-site/src/templates/prismicDoc.js b/site/gatsby-site/src/templates/prismicDoc.js index bdd1251871..1a49ab8930 100644 --- a/site/gatsby-site/src/templates/prismicDoc.js +++ b/site/gatsby-site/src/templates/prismicDoc.js @@ -1,6 +1,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import PrismicDocPost from 'components/doc/PrismicDocPost'; +import AiidHead from 'components/AiidHead'; export default function PrismicDoc(props) { const doc = props?.data?.doc; @@ -12,6 +13,24 @@ export default function PrismicDoc(props) { ); } +export const Head = (props) => { + const { + location: { pathname }, + } = props; + + const doc = props?.data?.doc; + + const metaTitle = doc?.data?.metaTitle; + + const metaDescription = doc?.data?.metaDescription; + + return ( + + {metaTitle} + + ); +}; + export const pageQuery = graphql` query Doc($slug: String!, $locale: String!) { site { From 3a626a20443be8ec27d9e6788c4b1509abaa08ec Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Fri, 19 Jan 2024 13:42:55 -0300 Subject: [PATCH 09/28] Fix blog page meta description --- .../i18n/locales/es/translation.json | 3 ++- .../i18n/locales/fr/translation.json | 3 ++- site/gatsby-site/src/pages/blog/index.js | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index 23bfa97150..3f585e8157 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -291,5 +291,6 @@ "results found": "resultados encontrados", "Artificial Intelligence Incident Database - Discover": "Base de datos de incidentes de inteligencia artificial - Descubrir", "AIID incidents list": "Lista de incidentes de AIID", - "Find AI related incidents and reports": "Encuentra incidentes e informes relacionados con la IA" + "Find AI related incidents and reports": "Encuentra incidentes e informes relacionados con la IA", + "Explore AIID's articles": "Explora los artículos de AIID" } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index d0005c7c7a..792c62d838 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -279,5 +279,6 @@ "results found": "résultats trouvés", "Artificial Intelligence Incident Database - Discover": "Base de données des incidents d'intelligence artificielle - Découvrir", "AIID incidents list": "Liste des incidents AIID", - "Find AI related incidents and reports": "Trouver des incidents et des rapports liés à l'IA" + "Find AI related incidents and reports": "Trouver des incidents et des rapports liés à l'IA", + "Explore AIID's articles": "Explorer les articles de l'AIID" } diff --git a/site/gatsby-site/src/pages/blog/index.js b/site/gatsby-site/src/pages/blog/index.js index 337dc1ce83..23f110ce7c 100644 --- a/site/gatsby-site/src/pages/blog/index.js +++ b/site/gatsby-site/src/pages/blog/index.js @@ -2,6 +2,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import PostsListing from 'components/blog/PostsListing'; import AiidHead from 'components/AiidHead'; +import { useTranslation } from 'react-i18next'; const BlogPage = (props) => { return ( @@ -18,11 +19,17 @@ const BlogPage = (props) => { export default BlogPage; -export const Head = (props) => ( - <> - - -); +export const Head = (props) => { + const { t } = useTranslation(); + + return ( + + ); +}; export const IndexQuery = graphql` query BlogPosts($locale: String!) { From 0918485f8a68a9d3af4d23d8533671be3df38db1 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Fri, 19 Jan 2024 14:00:32 -0300 Subject: [PATCH 10/28] Fix login and signup ogtags --- site/gatsby-site/i18n/locales/es/translation.json | 6 +++++- site/gatsby-site/i18n/locales/fr/translation.json | 6 +++++- site/gatsby-site/src/pages/login.js | 13 +++++++++++++ site/gatsby-site/src/pages/signup.js | 13 +++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index 3f585e8157..0f9dc891aa 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -292,5 +292,9 @@ "Artificial Intelligence Incident Database - Discover": "Base de datos de incidentes de inteligencia artificial - Descubrir", "AIID incidents list": "Lista de incidentes de AIID", "Find AI related incidents and reports": "Encuentra incidentes e informes relacionados con la IA", - "Explore AIID's articles": "Explora los artículos de AIID" + "Explore AIID's articles": "Explora los artículos de AIID", + "Sign up for an account": "Regístrate para obtener una cuenta", + "AIID - Sign Up": "AIID - Registrarse", + "AIID - Login": "AIID - Iniciar sesión", + "Login to your account": "Inicia sesión en tu cuenta" } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index 792c62d838..0de1f6d231 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -280,5 +280,9 @@ "Artificial Intelligence Incident Database - Discover": "Base de données des incidents d'intelligence artificielle - Découvrir", "AIID incidents list": "Liste des incidents AIID", "Find AI related incidents and reports": "Trouver des incidents et des rapports liés à l'IA", - "Explore AIID's articles": "Explorer les articles de l'AIID" + "Explore AIID's articles": "Explorer les articles de l'AIID", + "Sign up for an account": "Créer un compte", + "AIID - Sign Up": "AIID - Créer un compte", + "AIID - Login": "AIID - Se connecter", + "Login to your account": "Connectez-vous à votre compte" } diff --git a/site/gatsby-site/src/pages/login.js b/site/gatsby-site/src/pages/login.js index 3979460d52..f063b50aa5 100644 --- a/site/gatsby-site/src/pages/login.js +++ b/site/gatsby-site/src/pages/login.js @@ -9,6 +9,7 @@ import { Trans, useTranslation } from 'react-i18next'; import Link from '../components/ui/Link'; import { StringParam, useQueryParams, withDefault } from 'use-query-params'; import TextInputGroup from 'components/forms/TextInputGroup'; +import AiidHead from 'components/AiidHead'; const LoginSchema = Yup.object().shape({ email: Yup.string().email('Invalid email').required('Required'), @@ -179,4 +180,16 @@ const Login = (props) => { ); }; +export const Head = (props) => { + const { t } = useTranslation(); + + return ( + + ); +}; + export default Login; diff --git a/site/gatsby-site/src/pages/signup.js b/site/gatsby-site/src/pages/signup.js index 5670d77aa6..67006b3fac 100644 --- a/site/gatsby-site/src/pages/signup.js +++ b/site/gatsby-site/src/pages/signup.js @@ -14,6 +14,7 @@ import { faEnvelope } from '@fortawesome/free-solid-svg-icons'; import TextInputGroup from 'components/forms/TextInputGroup'; import NewsletterSignup from 'components/landing/NewsletterSignup'; import Card from 'elements/Card'; +import AiidHead from 'components/AiidHead'; const SignUpSchema = Yup.object().shape({ email: Yup.string().email('Invalid email').required('Required'), @@ -238,4 +239,16 @@ const SignUp = (props) => { ); }; +export const Head = (props) => { + const { t } = useTranslation(); + + return ( + + ); +}; + export default SignUp; From dc1b44dad5888c68374257b1d9bf5acd84d9fe74 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 23 Jan 2024 09:22:41 -0300 Subject: [PATCH 11/28] Remove unecessary fragment and children change --- site/gatsby-site/src/components/AiidHead.js | 2 +- site/gatsby-site/src/templates/blogPost.js | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index 98c33d116d..f96df36a6a 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -52,7 +52,7 @@ const AiidHead = ({ )} - {children && <>{children}} + {children} ); }; diff --git a/site/gatsby-site/src/templates/blogPost.js b/site/gatsby-site/src/templates/blogPost.js index fe7c963a82..986d4de8c9 100644 --- a/site/gatsby-site/src/templates/blogPost.js +++ b/site/gatsby-site/src/templates/blogPost.js @@ -13,14 +13,12 @@ export const Head = (props) => { const post = props?.data?.post; return ( - <> - - + ); }; From 95c30a9bfe6a647655d9b06c012adb3340cdab74 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 23 Jan 2024 11:52:00 -0300 Subject: [PATCH 12/28] Improve code, use fewer lines --- site/gatsby-site/src/components/AiidHead.js | 3 ++- site/gatsby-site/src/pages/404.js | 4 +--- site/gatsby-site/src/pages/account.js | 6 +----- site/gatsby-site/src/pages/admin/index.js | 6 +----- site/gatsby-site/src/pages/apps/checklists.js | 6 +----- site/gatsby-site/src/pages/apps/classifications.js | 6 +----- .../{mongodbAiidprodIncidents.incident_id}.js | 6 +----- site/gatsby-site/src/pages/apps/discover.js | 4 +--- site/gatsby-site/src/pages/apps/incidents.js | 6 +----- site/gatsby-site/src/pages/apps/newsdigest.js | 6 +----- site/gatsby-site/src/pages/apps/reports.js | 6 +----- site/gatsby-site/src/pages/apps/submit.js | 6 +----- site/gatsby-site/src/pages/apps/submitted.js | 6 +----- site/gatsby-site/src/pages/apps/variants.js | 6 +----- .../gatsby-site/src/pages/summaries/cset-charts.js | 7 +------ site/gatsby-site/src/pages/summaries/flagged.js | 6 +----- site/gatsby-site/src/pages/summaries/incidents.js | 6 +----- .../src/pages/summaries/incidentsOverTime.js | 7 +------ .../gatsby-site/src/pages/summaries/leaderboard.js | 6 +----- site/gatsby-site/src/pages/taxonomies.js | 13 ++++++++++--- site/gatsby-site/src/templates/backups.js | 6 +----- site/gatsby-site/src/templates/cite-duplicate.js | 6 +----- site/gatsby-site/src/templates/cite.js | 7 +------ site/gatsby-site/src/templates/doc.js | 6 +----- site/gatsby-site/src/templates/entities.js | 6 +----- site/gatsby-site/src/templates/entity.js | 6 +----- site/gatsby-site/src/templates/landingPage.js | 9 +++++---- site/gatsby-site/src/templates/post.js | 14 ++++++-------- site/gatsby-site/src/templates/prismicDoc.js | 6 +----- site/gatsby-site/src/templates/report.js | 6 ++---- .../src/templates/tsneVisualizationPage.js | 7 +------ site/gatsby-site/src/templates/wordcounts.js | 6 +----- 32 files changed, 52 insertions(+), 155 deletions(-) diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index f96df36a6a..c8fb5f9eae 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -8,6 +8,7 @@ const AiidHead = ({ path, metaImage = null, metaType = 'website', + title = null, }) => { const twitter = config.siteMetadata.twitterAccount; @@ -17,7 +18,7 @@ const AiidHead = ({ return ( <> - {metaTitle && {metaTitle}} + {title ? {title} : metaTitle ? {metaTitle} : <>} {metaTitle && } {metaTitle && } {metaTitle && } diff --git a/site/gatsby-site/src/pages/404.js b/site/gatsby-site/src/pages/404.js index 7da6e858d6..4d81306861 100644 --- a/site/gatsby-site/src/pages/404.js +++ b/site/gatsby-site/src/pages/404.js @@ -13,9 +13,7 @@ const Default404 = () => { }; export const Head = (props) => ( - - Page not found - + ); export default Default404; diff --git a/site/gatsby-site/src/pages/account.js b/site/gatsby-site/src/pages/account.js index d35e19d819..a61a408fb2 100644 --- a/site/gatsby-site/src/pages/account.js +++ b/site/gatsby-site/src/pages/account.js @@ -50,11 +50,7 @@ const Account = () => { export const Head = (props) => { const { t } = useTranslation(['account']); - return ( - - {t('Account Details')} - - ); + return ; }; export default Account; diff --git a/site/gatsby-site/src/pages/admin/index.js b/site/gatsby-site/src/pages/admin/index.js index 5d5d649e61..389736d10a 100644 --- a/site/gatsby-site/src/pages/admin/index.js +++ b/site/gatsby-site/src/pages/admin/index.js @@ -44,11 +44,7 @@ export const Head = (props) => { location: { pathname }, } = props; - return ( - - Admin - - ); + return ; }; export default AdminPage; diff --git a/site/gatsby-site/src/pages/apps/checklists.js b/site/gatsby-site/src/pages/apps/checklists.js index 3ef4fef89d..b389bfe55d 100644 --- a/site/gatsby-site/src/pages/apps/checklists.js +++ b/site/gatsby-site/src/pages/apps/checklists.js @@ -234,11 +234,7 @@ export const Head = (props) => { const { t } = useTranslation(); - return ( - - {t('Risk Checklists')} - - ); + return ; }; export default ChecklistsPage; diff --git a/site/gatsby-site/src/pages/apps/classifications.js b/site/gatsby-site/src/pages/apps/classifications.js index 0bf01ea9e2..db516bbc92 100644 --- a/site/gatsby-site/src/pages/apps/classifications.js +++ b/site/gatsby-site/src/pages/apps/classifications.js @@ -572,9 +572,5 @@ export const Head = (props) => { location: { pathname }, } = props; - return ( - - Artificial Intelligence Incident Database - - ); + return ; }; diff --git a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js index d317f85bd4..27576d35bc 100644 --- a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js +++ b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js @@ -90,11 +90,7 @@ export const Head = (props) => { const metaTitle = 'CSET Tool'; - return ( - - {metaTitle} - - ); + return ; }; export default ToolPage; diff --git a/site/gatsby-site/src/pages/apps/discover.js b/site/gatsby-site/src/pages/apps/discover.js index 8de5820094..72ccc908d2 100644 --- a/site/gatsby-site/src/pages/apps/discover.js +++ b/site/gatsby-site/src/pages/apps/discover.js @@ -25,9 +25,7 @@ export const Head = (props) => { path={pathname} metaTitle={metaTitle} metaDescription={t('Find AI related incidents and reports')} - > - {metaTitle} - + /> ); }; diff --git a/site/gatsby-site/src/pages/apps/incidents.js b/site/gatsby-site/src/pages/apps/incidents.js index 4bbbbcea86..499fc2c01b 100644 --- a/site/gatsby-site/src/pages/apps/incidents.js +++ b/site/gatsby-site/src/pages/apps/incidents.js @@ -75,11 +75,7 @@ export const Head = (props) => { const metaDescription = t('AIID incidents list'); - return ( - - {metaTitle} - - ); + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/pages/apps/newsdigest.js b/site/gatsby-site/src/pages/apps/newsdigest.js index cbdf3561ba..bd83a4a905 100644 --- a/site/gatsby-site/src/pages/apps/newsdigest.js +++ b/site/gatsby-site/src/pages/apps/newsdigest.js @@ -493,9 +493,5 @@ export const Head = (props) => { const title = t('Related News Digest'); - return ( - - {title} - - ); + return ; }; diff --git a/site/gatsby-site/src/pages/apps/reports.js b/site/gatsby-site/src/pages/apps/reports.js index a9e825c655..738bbd89e5 100644 --- a/site/gatsby-site/src/pages/apps/reports.js +++ b/site/gatsby-site/src/pages/apps/reports.js @@ -234,9 +234,5 @@ export const Head = (props) => { const metaTitle = t('Incident List'); - return ( - - {metaTitle} - - ); + return ; }; diff --git a/site/gatsby-site/src/pages/apps/submit.js b/site/gatsby-site/src/pages/apps/submit.js index 9dabdd73fb..4009f33317 100644 --- a/site/gatsby-site/src/pages/apps/submit.js +++ b/site/gatsby-site/src/pages/apps/submit.js @@ -20,11 +20,7 @@ export const Head = (props) => { const metaTitle = t('New Incident Report'); - return ( - - {metaTitle} - - ); + return ; }; export default SubmitPage; diff --git a/site/gatsby-site/src/pages/apps/submitted.js b/site/gatsby-site/src/pages/apps/submitted.js index 120a322a08..6fe7d3994f 100644 --- a/site/gatsby-site/src/pages/apps/submitted.js +++ b/site/gatsby-site/src/pages/apps/submitted.js @@ -190,11 +190,7 @@ export const Head = (props) => { const metaTitle = 'Submissions'; - return ( - - {metaTitle} - - ); + return ; }; export default SubmittedIncidentsPage; diff --git a/site/gatsby-site/src/pages/apps/variants.js b/site/gatsby-site/src/pages/apps/variants.js index 7846a79d88..03161eba4d 100644 --- a/site/gatsby-site/src/pages/apps/variants.js +++ b/site/gatsby-site/src/pages/apps/variants.js @@ -102,9 +102,5 @@ export const Head = (props) => { const metaTitle = t('Variants'); - return ( - - {metaTitle} - - ); + return ; }; diff --git a/site/gatsby-site/src/pages/summaries/cset-charts.js b/site/gatsby-site/src/pages/summaries/cset-charts.js index 2bb57279b0..6085652dbc 100644 --- a/site/gatsby-site/src/pages/summaries/cset-charts.js +++ b/site/gatsby-site/src/pages/summaries/cset-charts.js @@ -112,12 +112,7 @@ export const Head = (props) => { const metaTitle = 'CSET Charts'; - return ( - - {metaTitle} - - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/flagged.js b/site/gatsby-site/src/pages/summaries/flagged.js index e1a12cc96a..b6508ead5d 100644 --- a/site/gatsby-site/src/pages/summaries/flagged.js +++ b/site/gatsby-site/src/pages/summaries/flagged.js @@ -63,11 +63,7 @@ export const Head = (props) => { const metaTitle = 'Incident List'; - return ( - - {metaTitle} - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidents.js b/site/gatsby-site/src/pages/summaries/incidents.js index 1cea8c9069..4bc7d900f9 100644 --- a/site/gatsby-site/src/pages/summaries/incidents.js +++ b/site/gatsby-site/src/pages/summaries/incidents.js @@ -130,11 +130,7 @@ export const Head = (props) => { const metaTitle = t('Incident List', { ns: 'incidents' }); - return ( - - {metaTitle} - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js index 62c3f9242a..ed9421ed6e 100644 --- a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js +++ b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js @@ -122,12 +122,7 @@ export const Head = (props) => { const metaTitle = 'Incidents Over Time'; - return ( - - {metaTitle} - - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/leaderboard.js b/site/gatsby-site/src/pages/summaries/leaderboard.js index bfe339e944..ee103d57af 100644 --- a/site/gatsby-site/src/pages/summaries/leaderboard.js +++ b/site/gatsby-site/src/pages/summaries/leaderboard.js @@ -42,9 +42,5 @@ export const Head = (props) => { const metaTitle = 'Submissions Leaderboard'; - return ( - - {metaTitle} - - ); + return ; }; diff --git a/site/gatsby-site/src/pages/taxonomies.js b/site/gatsby-site/src/pages/taxonomies.js index ad7dca1b0a..7944d064bc 100644 --- a/site/gatsby-site/src/pages/taxonomies.js +++ b/site/gatsby-site/src/pages/taxonomies.js @@ -71,6 +71,10 @@ export default function Taxonomies({ data }) { export const Head = (props) => { const { t } = useTranslation(); + const { + location: { pathname }, + } = props; + const title = t('Taxonomies'); const metaTitle = t('List of taxonomies'); @@ -78,9 +82,12 @@ export const Head = (props) => { const metaDescription = t('This is the list of taxonomies supported in AIID'); return ( - - {title} - + ); }; diff --git a/site/gatsby-site/src/templates/backups.js b/site/gatsby-site/src/templates/backups.js index 6a9fa613cd..2a0cc3209d 100644 --- a/site/gatsby-site/src/templates/backups.js +++ b/site/gatsby-site/src/templates/backups.js @@ -112,11 +112,7 @@ export const Head = (props) => { const metaTitle = 'Database Backups and Snapshots'; - return ( - - {metaTitle} - - ); + return ; }; export default Backups; diff --git a/site/gatsby-site/src/templates/cite-duplicate.js b/site/gatsby-site/src/templates/cite-duplicate.js index 5b5d90e74e..86726b8f83 100644 --- a/site/gatsby-site/src/templates/cite-duplicate.js +++ b/site/gatsby-site/src/templates/cite-duplicate.js @@ -41,11 +41,7 @@ export const Head = (props) => { const canonicalUrl = getCanonicalUrl(true_incident_number); - return ( - - {metaTitle} - - ); + return ; }; export default IncidentCite; diff --git a/site/gatsby-site/src/templates/cite.js b/site/gatsby-site/src/templates/cite.js index ad0003b0ca..0e18ab8e62 100644 --- a/site/gatsby-site/src/templates/cite.js +++ b/site/gatsby-site/src/templates/cite.js @@ -156,12 +156,7 @@ export const Head = (props) => { const metaImage = image.createCloudinaryURL(); - return ( - - {metaTitle} - - - ); + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/templates/doc.js b/site/gatsby-site/src/templates/doc.js index f08c2a25c3..04f3ffafd1 100644 --- a/site/gatsby-site/src/templates/doc.js +++ b/site/gatsby-site/src/templates/doc.js @@ -56,11 +56,7 @@ export const Head = (props) => { const metaDescription = mdx.frontmatter.metaDescription; - return ( - - {metaTitle} - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/entities.js b/site/gatsby-site/src/templates/entities.js index f0409e9b0d..6d6adfca2c 100644 --- a/site/gatsby-site/src/templates/entities.js +++ b/site/gatsby-site/src/templates/entities.js @@ -75,11 +75,7 @@ export const Head = (props) => { const canonicalUrl = 'https://incidentdatabase.ai/entities'; - return ( - - {metaTitle} - - ); + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/templates/entity.js b/site/gatsby-site/src/templates/entity.js index eb49030603..0e0427241b 100644 --- a/site/gatsby-site/src/templates/entity.js +++ b/site/gatsby-site/src/templates/entity.js @@ -296,11 +296,7 @@ export const Head = (props) => { const metaTitle = 'Entity: ' + name; - return ( - - {metaTitle} - - ); + return ; }; function UnsubscribeButton({ diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index 92c59f57f9..d2c94aa637 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -170,10 +170,11 @@ export function Head({ location }) { return ( <> - {title} - - - + ); } diff --git a/site/gatsby-site/src/templates/post.js b/site/gatsby-site/src/templates/post.js index edb14d5854..de8155af91 100644 --- a/site/gatsby-site/src/templates/post.js +++ b/site/gatsby-site/src/templates/post.js @@ -92,14 +92,12 @@ export const Head = (props) => { } return ( - <> - - + ); }; diff --git a/site/gatsby-site/src/templates/prismicDoc.js b/site/gatsby-site/src/templates/prismicDoc.js index 1a49ab8930..a7b41beaec 100644 --- a/site/gatsby-site/src/templates/prismicDoc.js +++ b/site/gatsby-site/src/templates/prismicDoc.js @@ -24,11 +24,7 @@ export const Head = (props) => { const metaDescription = doc?.data?.metaDescription; - return ( - - {metaTitle} - - ); + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/report.js b/site/gatsby-site/src/templates/report.js index 6606066fae..c3853f545d 100644 --- a/site/gatsby-site/src/templates/report.js +++ b/site/gatsby-site/src/templates/report.js @@ -95,10 +95,8 @@ export const Head = (props) => { metaDescription: report.description, metaImage: report.image_url, }} - > - {metaTitle} - - + metaType="website" + /> ); }; diff --git a/site/gatsby-site/src/templates/tsneVisualizationPage.js b/site/gatsby-site/src/templates/tsneVisualizationPage.js index 5a555c622b..8fe72c85ec 100644 --- a/site/gatsby-site/src/templates/tsneVisualizationPage.js +++ b/site/gatsby-site/src/templates/tsneVisualizationPage.js @@ -65,12 +65,7 @@ export const Head = (props) => { const metaDescription = t('Spatial Visualization'); - return ( - - {metaTitle} - - - ); + return ; }; export default TsneVisulizationPage; diff --git a/site/gatsby-site/src/templates/wordcounts.js b/site/gatsby-site/src/templates/wordcounts.js index 67e2f76e9d..a7913a61e8 100644 --- a/site/gatsby-site/src/templates/wordcounts.js +++ b/site/gatsby-site/src/templates/wordcounts.js @@ -79,11 +79,7 @@ export const Head = (props) => { const metaTitle = 'Word Counts'; - return ( - - {metaTitle} - - ); + return ; }; export default WordCounts; From f6f601cccfb925728d124b7dc2f0ead445d438a4 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 7 Feb 2024 15:11:31 -0300 Subject: [PATCH 13/28] Remove wrong name title og element and revert tests --- .../cypress/e2e/integration/submit.cy.js | 32 +++++++++---------- site/gatsby-site/src/components/AiidHead.js | 1 - 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/submit.cy.js b/site/gatsby-site/cypress/e2e/integration/submit.cy.js index a1b0119e0e..8159eb0746 100644 --- a/site/gatsby-site/cypress/e2e/integration/submit.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/submit.cy.js @@ -737,13 +737,13 @@ describe('The Submit form', () => { for (const key in values) { if (key == 'incident_ids') { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); } } @@ -836,13 +836,13 @@ describe('The Submit form', () => { for (const key in values) { if (key == 'incident_ids') { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); } } @@ -903,7 +903,7 @@ describe('The Submit form', () => { }; for (const key in values) { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); } cy.clickOutside(); @@ -1010,7 +1010,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep1) { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); } cy.setEditorText( @@ -1159,7 +1159,7 @@ describe('The Submit form', () => { const keys = ['url', 'title', 'authors', 'incident_date']; keys.forEach((key) => { - cy.get(`input[name="${key}"]`).should('have.value', ''); + cy.get(`[name="${key}"]`).should('have.value', ''); }); }); @@ -1210,7 +1210,7 @@ describe('The Submit form', () => { const keys = ['url', 'title', 'authors', 'incident_date']; keys.forEach((key) => { - cy.get(`input[name="${key}"]`).should('have.value', ''); + cy.get(`[name="${key}"]`).should('have.value', ''); }); }); @@ -1359,7 +1359,7 @@ describe('The Submit form', () => { }; for (const key in values) { - cy.get(`input[name="${key}"]`).type(values[key]); + cy.get(`[name="${key}"]`).type(values[key]); } cy.setEditorText( @@ -1416,7 +1416,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep1) { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); } cy.clickOutside(); @@ -1471,13 +1471,13 @@ describe('The Submit form', () => { for (const key in valuesStep1) { if (key == 'incident_ids') { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); } } @@ -1498,7 +1498,7 @@ describe('The Submit form', () => { }; for (const key in valuesStep2) { - cy.get(`input[name="${key}"]`).type(valuesStep2[key]); + cy.get(`[name="${key}"]`).type(valuesStep2[key]); } cy.get('[data-cy="to-step-3"]').click(); @@ -1687,13 +1687,13 @@ describe('The Submit form', () => { for (const key in valuesStep1) { if (key == 'incident_ids') { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`input[name="${key}"]`).type(valuesStep1[key]); + cy.get(`[name="${key}"]`).type(valuesStep1[key]); } } @@ -1790,7 +1790,7 @@ describe('The Submit form', () => { cy.waitForStableDOM(); for (const key in values) { - cy.get(`input[name="${key}"]`).should('have.value', ''); + cy.get(`[name="${key}"]`).should('have.value', ''); } }); diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index c8fb5f9eae..1683f4fde8 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -19,7 +19,6 @@ const AiidHead = ({ return ( <> {title ? {title} : metaTitle ? {metaTitle} : <>} - {metaTitle && } {metaTitle && } {metaTitle && } {metaDescription && } From d75fc14207b23c527e0e499155b8003aa5f4b703 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 7 Feb 2024 15:13:14 -0300 Subject: [PATCH 14/28] Revert test inputs --- .../cypress/e2e/integration/submit.cy.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/submit.cy.js b/site/gatsby-site/cypress/e2e/integration/submit.cy.js index 8159eb0746..2ab56406b7 100644 --- a/site/gatsby-site/cypress/e2e/integration/submit.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/submit.cy.js @@ -737,13 +737,13 @@ describe('The Submit form', () => { for (const key in values) { if (key == 'incident_ids') { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); } } @@ -836,13 +836,13 @@ describe('The Submit form', () => { for (const key in values) { if (key == 'incident_ids') { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); cy.waitForStableDOM(); cy.get(`[role="option"]`).first().click(); } else { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); } } @@ -903,7 +903,7 @@ describe('The Submit form', () => { }; for (const key in values) { - cy.get(`[name="${key}"]`).type(values[key]); + cy.get(`input[name="${key}"]`).type(values[key]); } cy.clickOutside(); @@ -1210,7 +1210,7 @@ describe('The Submit form', () => { const keys = ['url', 'title', 'authors', 'incident_date']; keys.forEach((key) => { - cy.get(`[name="${key}"]`).should('have.value', ''); + cy.get(`input[name="${key}"]`).should('have.value', ''); }); }); @@ -1471,7 +1471,7 @@ describe('The Submit form', () => { for (const key in valuesStep1) { if (key == 'incident_ids') { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); cy.waitForStableDOM(); @@ -1687,7 +1687,7 @@ describe('The Submit form', () => { for (const key in valuesStep1) { if (key == 'incident_ids') { - cy.get(`[name="${key}"]`).type(valuesStep1[key]); + cy.get(`input[name="${key}"]`).type(valuesStep1[key]); cy.waitForStableDOM(); @@ -1790,7 +1790,7 @@ describe('The Submit form', () => { cy.waitForStableDOM(); for (const key in values) { - cy.get(`[name="${key}"]`).should('have.value', ''); + cy.get(`input[name="${key}"]`).should('have.value', ''); } }); From 4e65333e2f6ddc89377d810301678877b779f296 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 7 Feb 2024 15:13:47 -0300 Subject: [PATCH 15/28] revert input type on cypress search --- site/gatsby-site/cypress/e2e/integration/submit.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/gatsby-site/cypress/e2e/integration/submit.cy.js b/site/gatsby-site/cypress/e2e/integration/submit.cy.js index 2ab56406b7..0e25ddee2a 100644 --- a/site/gatsby-site/cypress/e2e/integration/submit.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/submit.cy.js @@ -1159,7 +1159,7 @@ describe('The Submit form', () => { const keys = ['url', 'title', 'authors', 'incident_date']; keys.forEach((key) => { - cy.get(`[name="${key}"]`).should('have.value', ''); + cy.get(`input[name="${key}"]`).should('have.value', ''); }); }); From cd27de7b641ccd0192919eab0604b87931a7a5e7 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 7 Feb 2024 16:57:20 -0300 Subject: [PATCH 16/28] Add test to check for og tags in pages and fix prismic doc og tags --- .../cypress/e2e/integration/blog.cy.js | 1 - .../cypress/e2e/integration/cite.cy.js | 1 - .../cypress/e2e/integration/pages.cy.js | 19 +++++++++++++++++++ site/gatsby-site/src/components/AiidHead.js | 2 +- site/gatsby-site/src/templates/prismicDoc.js | 4 ++-- site/gatsby-site/src/templates/report.js | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/blog.cy.js b/site/gatsby-site/cypress/e2e/integration/blog.cy.js index ac75a9ca7e..ec91e3bb7c 100644 --- a/site/gatsby-site/cypress/e2e/integration/blog.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/blog.cy.js @@ -54,7 +54,6 @@ describe('Blog', () => { cy.title().should('eq', title); - cy.get('head meta[name="title"]').should('have.attr', 'content', title); cy.get('head meta[name="description"]').should('have.attr', 'content', description); cy.get('head meta[name="twitter:site"]').should('have.attr', 'content', '@IncidentsDB'); diff --git a/site/gatsby-site/cypress/e2e/integration/cite.cy.js b/site/gatsby-site/cypress/e2e/integration/cite.cy.js index 9053869688..4673cbdad8 100644 --- a/site/gatsby-site/cypress/e2e/integration/cite.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/cite.cy.js @@ -574,7 +574,6 @@ describe('Cite pages', () => { const description = incident.description; - cy.get('head meta[name="title"]').should('have.attr', 'content', title); cy.get('head meta[name="description"]').should('have.attr', 'content', description); cy.get('head meta[name="twitter:site"]').should('have.attr', 'content', '@IncidentsDB'); diff --git a/site/gatsby-site/cypress/e2e/integration/pages.cy.js b/site/gatsby-site/cypress/e2e/integration/pages.cy.js index 7f2ae0a867..7fb2245631 100644 --- a/site/gatsby-site/cypress/e2e/integration/pages.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/pages.cy.js @@ -162,6 +162,25 @@ describe('Pages', () => { }); } ); + + it.only(`/${code}${path} Should have open graph tags`, () => { + const canonicalPath = switchLocalizedPath({ newLang: code, path }); + + cy.visit(canonicalPath); + cy.get('head meta[name="description"]').should('exist'); + + cy.get('head meta[name="twitter:site"]').should('exist'); + cy.get('head meta[name="twitter:creator"]').should('exist'); + + cy.get('head meta[property="og:url"]').should('exist'); + cy.get('head meta[property="og:type"]').should('exist'); + cy.get('head meta[property="og:title"]').should('exist'); + cy.get('head meta[property="og:description"]').should('exist'); + cy.get('head meta[property="og:image"]').first().should('exist'); + cy.get('head meta[property="twitter:title"]').should('exist'); + cy.get('head meta[property="twitter:description"]').should('exist'); + cy.get('head meta[property="twitter:image"]').should('exist'); + }); }); }); }); diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index 1683f4fde8..72257a48e6 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -4,7 +4,7 @@ import config from '../../config'; const AiidHead = ({ children, metaTitle = null, - metaDescription = null, + metaDescription = metaTitle, path, metaImage = null, metaType = 'website', diff --git a/site/gatsby-site/src/templates/prismicDoc.js b/site/gatsby-site/src/templates/prismicDoc.js index a7b41beaec..0fb3e29725 100644 --- a/site/gatsby-site/src/templates/prismicDoc.js +++ b/site/gatsby-site/src/templates/prismicDoc.js @@ -20,9 +20,9 @@ export const Head = (props) => { const doc = props?.data?.doc; - const metaTitle = doc?.data?.metaTitle; + const metaTitle = doc?.data?.metatitle; - const metaDescription = doc?.data?.metaDescription; + const metaDescription = doc?.data?.metadescription; return ; }; diff --git a/site/gatsby-site/src/templates/report.js b/site/gatsby-site/src/templates/report.js index c3853f545d..a44833c305 100644 --- a/site/gatsby-site/src/templates/report.js +++ b/site/gatsby-site/src/templates/report.js @@ -92,7 +92,7 @@ export const Head = (props) => { path={pathname} {...{ metaTitle, - metaDescription: report.description, + metaDescription: report.description || metaTitle, metaImage: report.image_url, }} metaType="website" From b43bc9a6f9cd7e55c85320af5fb35d162426e756 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Fri, 9 Feb 2024 14:24:07 -0300 Subject: [PATCH 17/28] Remove wrongly defined description item --- site/gatsby-site/cypress/e2e/integration/pages.cy.js | 3 +-- site/gatsby-site/src/components/AiidHead.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/pages.cy.js b/site/gatsby-site/cypress/e2e/integration/pages.cy.js index 7fb2245631..ae20246ac1 100644 --- a/site/gatsby-site/cypress/e2e/integration/pages.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/pages.cy.js @@ -163,11 +163,10 @@ describe('Pages', () => { } ); - it.only(`/${code}${path} Should have open graph tags`, () => { + it(`/${code}${path} Should have open graph tags`, () => { const canonicalPath = switchLocalizedPath({ newLang: code, path }); cy.visit(canonicalPath); - cy.get('head meta[name="description"]').should('exist'); cy.get('head meta[name="twitter:site"]').should('exist'); cy.get('head meta[name="twitter:creator"]').should('exist'); diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index 72257a48e6..95059bdd6d 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -23,7 +23,6 @@ const AiidHead = ({ {metaTitle && } {metaDescription && } {metaDescription && } - {metaDescription && } {metaImage && } {metaImage && } From 956118419441b197985844ac8486483f774b57a4 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 13 Feb 2024 12:26:38 -0300 Subject: [PATCH 18/28] Fix tests for blog and cite og --- site/gatsby-site/cypress/e2e/integration/blog.cy.js | 2 -- site/gatsby-site/cypress/e2e/integration/cite.cy.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/site/gatsby-site/cypress/e2e/integration/blog.cy.js b/site/gatsby-site/cypress/e2e/integration/blog.cy.js index ec91e3bb7c..dad86b48a5 100644 --- a/site/gatsby-site/cypress/e2e/integration/blog.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/blog.cy.js @@ -54,8 +54,6 @@ describe('Blog', () => { cy.title().should('eq', title); - cy.get('head meta[name="description"]').should('have.attr', 'content', description); - cy.get('head meta[name="twitter:site"]').should('have.attr', 'content', '@IncidentsDB'); cy.get('head meta[name="twitter:creator"]').should('have.attr', 'content', '@IncidentsDB'); diff --git a/site/gatsby-site/cypress/e2e/integration/cite.cy.js b/site/gatsby-site/cypress/e2e/integration/cite.cy.js index 5c0f844d40..18c9f86025 100644 --- a/site/gatsby-site/cypress/e2e/integration/cite.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/cite.cy.js @@ -579,8 +579,6 @@ describe('Cite pages', () => { const description = incident.description; - cy.get('head meta[name="description"]').should('have.attr', 'content', description); - cy.get('head meta[name="twitter:site"]').should('have.attr', 'content', '@IncidentsDB'); cy.get('head meta[name="twitter:creator"]').should('have.attr', 'content', '@IncidentsDB'); From 5398608d6dcd38e0d01d36e396272ff39746fe00 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 13 Feb 2024 13:41:05 -0300 Subject: [PATCH 19/28] Add wait for stable dom --- site/gatsby-site/cypress/e2e/integration/pages.cy.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/gatsby-site/cypress/e2e/integration/pages.cy.js b/site/gatsby-site/cypress/e2e/integration/pages.cy.js index ab1af863c6..1d554e8cf6 100644 --- a/site/gatsby-site/cypress/e2e/integration/pages.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/pages.cy.js @@ -169,6 +169,8 @@ describe('Pages', () => { cy.visit(canonicalPath); + cy.waitForStableDOM(); + cy.get('head meta[name="twitter:site"]').should('exist'); cy.get('head meta[name="twitter:creator"]').should('exist'); From c9605bd477e7c74ec1b12d75feba47b5835b8967 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 19 Feb 2024 13:01:30 -0300 Subject: [PATCH 20/28] Fix hidration error on landing --- site/gatsby-site/src/templates/landingPage.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index bec92b7c4b..19b355dc2a 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import Featured from 'components/landing/Featured'; import Leaderboards from 'components/landing/Leaderboards'; import Blog from 'components/landing/Blog'; @@ -26,20 +26,22 @@ const LandingPage = (props) => { const { latestReportNumbers } = props.pageContext; - let latestBlogPost = null; + const [latestBlogPost, setLatestBlogPost] = useState(null); - if (!latestPostOld || latestPostOld.nodes.length === 0) { - latestBlogPost = latestPrismicPost; - } else if (!latestPrismicPost || latestPrismicPost.nodes.length === 0) { - latestBlogPost = latestPostOld; - } else { - const mdxDate = new Date(latestPostOld?.nodes[0]?.frontmatter?.date); + useEffect(() => { + if (!latestPostOld || latestPostOld.nodes.length === 0) { + setLatestBlogPost(latestPrismicPost); + } else if (!latestPrismicPost || latestPrismicPost.nodes.length === 0) { + setLatestBlogPost(latestPostOld); + } else { + const mdxDate = new Date(latestPostOld?.nodes[0]?.frontmatter?.date); - const prismicDate = new Date(latestPrismicPost?.nodes[0]?.data.date); + const prismicDate = new Date(latestPrismicPost?.nodes[0]?.data.date); - // Display prismic post if it's the latest post or if it's newer than the latest mdx post - latestBlogPost = mdxDate > prismicDate ? latestPostOld : latestPrismicPost; - } + // Display prismic post if it's the latest post or if it's newer than the latest mdx post + setLatestBlogPost(mdxDate > prismicDate ? latestPostOld : latestPrismicPost); + } + }, [latestPostOld, latestPrismicPost, latestReportIncidents]); let { sponsors } = props.pageContext; From e2cc5b5a97ed98b0b6b3137d0422b24372dcd8d0 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 19 Feb 2024 13:09:03 -0300 Subject: [PATCH 21/28] Fix hydration issues on blog page --- .../src/components/blog/PostsListing.js | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/site/gatsby-site/src/components/blog/PostsListing.js b/site/gatsby-site/src/components/blog/PostsListing.js index fe272848d1..14c4b77f7c 100644 --- a/site/gatsby-site/src/components/blog/PostsListing.js +++ b/site/gatsby-site/src/components/blog/PostsListing.js @@ -1,24 +1,31 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import PostPreview from './PostPreview'; import PrismicPostPreview from './PrismicPostPreview'; export default function PostsListing({ posts, mdxBlogPosts }) { - // Add an mdx field to each object and flatten the structure - const mdxBlogPostsWithFlag = mdxBlogPosts.map((post) => ({ - ...post, - date: post.frontmatter.date, - mdx: true, - })); + const [sortedPosts, setSortedPosts] = useState([]); - const postsWithFlag = posts.map((post) => ({ - ...post, - date: post.node.data.date, - mdx: false, - })); + useEffect(() => { + // Add an mdx field to each object and flatten the structure + const mdxBlogPostsWithFlag = mdxBlogPosts.map((post) => ({ + ...post, + date: post.frontmatter.date, + mdx: true, + })); - const mergedPosts = [...mdxBlogPostsWithFlag, ...postsWithFlag]; + const postsWithFlag = posts.map((post) => ({ + ...post, + date: post.node.data.date, + mdx: false, + })); - const sortedPosts = mergedPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); + const mergedPosts = [...mdxBlogPostsWithFlag, ...postsWithFlag]; + + const sortedPosts = mergedPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); + + setSortedPosts(sortedPosts); + }), + [posts, mdxBlogPosts]; return ( <> From c585a99342132475c8b17d5c0ed450993a2af930 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 22 Feb 2024 11:33:46 -0300 Subject: [PATCH 22/28] Remove duplicated code --- site/gatsby-site/src/components/AiidHead.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/AiidHead.js index 95059bdd6d..334f7a1a15 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/AiidHead.js @@ -26,18 +26,6 @@ const AiidHead = ({ {metaImage && } {metaImage && } - {/* Provide default image even when a metaImage is supplied - * to act as a fallback in case provided one fails to load. - * Some sites also allow users to pick from the available meta images - * if multiple are available. - */} - {config.siteMetadata.ogImage && ( - - )} - {config.siteMetadata.ogImage && ( - - )} - {twitter && } From 71f4569b2143e3448a5e33ec3f4950f2a71a18f7 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 26 Feb 2024 09:57:21 -0300 Subject: [PATCH 23/28] Rename AiidHead to HeadContent --- .../src/components/{AiidHead.js => HeadContent.js} | 4 ++-- site/gatsby-site/src/pages/404.js | 4 ++-- site/gatsby-site/src/pages/account.js | 4 ++-- site/gatsby-site/src/pages/admin/index.js | 4 ++-- site/gatsby-site/src/pages/apps/checklists.js | 4 ++-- site/gatsby-site/src/pages/apps/classifications.js | 4 ++-- .../apps/csettool/{mongodbAiidprodIncidents.incident_id}.js | 4 ++-- site/gatsby-site/src/pages/apps/discover.js | 4 ++-- site/gatsby-site/src/pages/apps/incidents.js | 4 ++-- site/gatsby-site/src/pages/apps/newsdigest.js | 4 ++-- site/gatsby-site/src/pages/apps/reports.js | 4 ++-- site/gatsby-site/src/pages/apps/submit.js | 4 ++-- site/gatsby-site/src/pages/apps/submitted.js | 4 ++-- site/gatsby-site/src/pages/apps/variants.js | 4 ++-- site/gatsby-site/src/pages/blog/index.js | 4 ++-- site/gatsby-site/src/pages/login.js | 4 ++-- site/gatsby-site/src/pages/signup.js | 4 ++-- site/gatsby-site/src/pages/summaries/cset-charts.js | 4 ++-- site/gatsby-site/src/pages/summaries/flagged.js | 4 ++-- site/gatsby-site/src/pages/summaries/incidents.js | 4 ++-- site/gatsby-site/src/pages/summaries/incidentsOverTime.js | 4 ++-- site/gatsby-site/src/pages/summaries/leaderboard.js | 4 ++-- site/gatsby-site/src/pages/taxonomies.js | 4 ++-- site/gatsby-site/src/templates/backups.js | 4 ++-- site/gatsby-site/src/templates/blogPost.js | 4 ++-- site/gatsby-site/src/templates/cite-duplicate.js | 4 ++-- site/gatsby-site/src/templates/cite.js | 4 ++-- site/gatsby-site/src/templates/doc.js | 4 ++-- site/gatsby-site/src/templates/entities.js | 4 ++-- site/gatsby-site/src/templates/entity.js | 4 ++-- site/gatsby-site/src/templates/landingPage.js | 4 ++-- site/gatsby-site/src/templates/post.js | 4 ++-- site/gatsby-site/src/templates/prismicDoc.js | 4 ++-- site/gatsby-site/src/templates/report.js | 4 ++-- site/gatsby-site/src/templates/taxonomy.js | 4 ++-- site/gatsby-site/src/templates/tsneVisualizationPage.js | 4 ++-- site/gatsby-site/src/templates/wordcounts.js | 4 ++-- 37 files changed, 74 insertions(+), 74 deletions(-) rename site/gatsby-site/src/components/{AiidHead.js => HeadContent.js} (96%) diff --git a/site/gatsby-site/src/components/AiidHead.js b/site/gatsby-site/src/components/HeadContent.js similarity index 96% rename from site/gatsby-site/src/components/AiidHead.js rename to site/gatsby-site/src/components/HeadContent.js index 334f7a1a15..d9c2bf31d2 100644 --- a/site/gatsby-site/src/components/AiidHead.js +++ b/site/gatsby-site/src/components/HeadContent.js @@ -1,7 +1,7 @@ import React from 'react'; import config from '../../config'; -const AiidHead = ({ +const HeadContent = ({ children, metaTitle = null, metaDescription = metaTitle, @@ -44,4 +44,4 @@ const AiidHead = ({ ); }; -export default AiidHead; +export default HeadContent; diff --git a/site/gatsby-site/src/pages/404.js b/site/gatsby-site/src/pages/404.js index 4d81306861..359bee0369 100644 --- a/site/gatsby-site/src/pages/404.js +++ b/site/gatsby-site/src/pages/404.js @@ -1,4 +1,4 @@ -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import React from 'react'; const Default404 = () => { @@ -13,7 +13,7 @@ const Default404 = () => { }; export const Head = (props) => ( - + ); export default Default404; diff --git a/site/gatsby-site/src/pages/account.js b/site/gatsby-site/src/pages/account.js index a61a408fb2..7f306d57e3 100644 --- a/site/gatsby-site/src/pages/account.js +++ b/site/gatsby-site/src/pages/account.js @@ -5,7 +5,7 @@ import { Trans, useTranslation } from 'react-i18next'; import Link from 'components/ui/Link'; import UserSubscriptions from 'components/UserSubscriptions'; import UserDetails from 'components/users/UserDetails'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const Account = () => { const { user, loading } = useUserContext(); @@ -50,7 +50,7 @@ const Account = () => { export const Head = (props) => { const { t } = useTranslation(['account']); - return ; + return ; }; export default Account; diff --git a/site/gatsby-site/src/pages/admin/index.js b/site/gatsby-site/src/pages/admin/index.js index 389736d10a..efe69b7c9c 100644 --- a/site/gatsby-site/src/pages/admin/index.js +++ b/site/gatsby-site/src/pages/admin/index.js @@ -8,7 +8,7 @@ import { Button } from 'flowbite-react'; import { Trans } from 'react-i18next'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; import useLocalizePath from 'components/i18n/useLocalizePath'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const AdminPage = (props) => { const { data, loading } = useQuery(FIND_USERS); @@ -44,7 +44,7 @@ export const Head = (props) => { location: { pathname }, } = props; - return ; + return ; }; export default AdminPage; diff --git a/site/gatsby-site/src/pages/apps/checklists.js b/site/gatsby-site/src/pages/apps/checklists.js index b389bfe55d..9c33193919 100644 --- a/site/gatsby-site/src/pages/apps/checklists.js +++ b/site/gatsby-site/src/pages/apps/checklists.js @@ -12,7 +12,7 @@ import CheckListForm from 'components/checklists/CheckListForm'; import ChecklistsIndex from 'components/checklists/ChecklistsIndex'; import { removeTypename, checkedRiskStatus } from 'utils/checklists'; import { FIND_CHECKLIST, UPDATE_CHECKLIST } from '../../graphql/checklists'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const ChecklistsPage = (props) => { const { data } = props; @@ -234,7 +234,7 @@ export const Head = (props) => { const { t } = useTranslation(); - return ; + return ; }; export default ChecklistsPage; diff --git a/site/gatsby-site/src/pages/apps/classifications.js b/site/gatsby-site/src/pages/apps/classifications.js index db516bbc92..74d4a45407 100644 --- a/site/gatsby-site/src/pages/apps/classifications.js +++ b/site/gatsby-site/src/pages/apps/classifications.js @@ -19,7 +19,7 @@ import Table, { SelectDatePickerFilter, } from 'components/ui/Table'; import { v4 as uuidv4 } from 'uuid'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const DEFAULT_EMPTY_CELL_DATA = '-'; @@ -572,5 +572,5 @@ export const Head = (props) => { location: { pathname }, } = props; - return ; + return ; }; diff --git a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js index 27576d35bc..00088c1e10 100644 --- a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js +++ b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { useQuery } from '@apollo/client/react'; import ListSkeleton from 'elements/Skeletons/List'; import { FIND_CLASSIFICATION } from '../../../graphql/classifications'; @@ -90,7 +90,7 @@ export const Head = (props) => { const metaTitle = 'CSET Tool'; - return ; + return ; }; export default ToolPage; diff --git a/site/gatsby-site/src/pages/apps/discover.js b/site/gatsby-site/src/pages/apps/discover.js index 72ccc908d2..89f9212847 100644 --- a/site/gatsby-site/src/pages/apps/discover.js +++ b/site/gatsby-site/src/pages/apps/discover.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import Discover from 'components/discover/Discover'; import { useTranslation } from 'react-i18next'; @@ -21,7 +21,7 @@ export const Head = (props) => { const metaTitle = t('Artificial Intelligence Incident Database - Discover'); return ( - { const metaDescription = t('AIID incidents list'); - return ; + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/pages/apps/newsdigest.js b/site/gatsby-site/src/pages/apps/newsdigest.js index bd83a4a905..d17169d91f 100644 --- a/site/gatsby-site/src/pages/apps/newsdigest.js +++ b/site/gatsby-site/src/pages/apps/newsdigest.js @@ -13,7 +13,7 @@ import { faTag, faBolt, } from '@fortawesome/free-solid-svg-icons'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { useUserContext } from 'contexts/userContext'; import CardSkeleton from 'elements/Skeletons/Card'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; @@ -493,5 +493,5 @@ export const Head = (props) => { const title = t('Related News Digest'); - return ; + return ; }; diff --git a/site/gatsby-site/src/pages/apps/reports.js b/site/gatsby-site/src/pages/apps/reports.js index 738bbd89e5..8f526edafe 100644 --- a/site/gatsby-site/src/pages/apps/reports.js +++ b/site/gatsby-site/src/pages/apps/reports.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHead from '../../components/AiidHead'; +import HeadContent from '../../components/HeadContent'; import Link from '../../components/ui/Link'; import { faLink } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; @@ -234,5 +234,5 @@ export const Head = (props) => { const metaTitle = t('Incident List'); - return ; + return ; }; diff --git a/site/gatsby-site/src/pages/apps/submit.js b/site/gatsby-site/src/pages/apps/submit.js index 4009f33317..0863c706e8 100644 --- a/site/gatsby-site/src/pages/apps/submit.js +++ b/site/gatsby-site/src/pages/apps/submit.js @@ -1,6 +1,6 @@ import React from 'react'; import SubmitForm from 'components/forms/SubmitForm'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { useTranslation } from 'react-i18next'; const SubmitPage = (props) => { @@ -20,7 +20,7 @@ export const Head = (props) => { const metaTitle = t('New Incident Report'); - return ; + return ; }; export default SubmitPage; diff --git a/site/gatsby-site/src/pages/apps/submitted.js b/site/gatsby-site/src/pages/apps/submitted.js index 6fe7d3994f..e9a85c955b 100644 --- a/site/gatsby-site/src/pages/apps/submitted.js +++ b/site/gatsby-site/src/pages/apps/submitted.js @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import AiidHead from '../../components/AiidHead'; +import HeadContent from '../../components/HeadContent'; import { ObjectId } from 'bson'; import { useMutation, useQuery } from '@apollo/client'; import { DELETE_QUICKADD, FIND_QUICKADD } from '../../graphql/quickadd.js'; @@ -190,7 +190,7 @@ export const Head = (props) => { const metaTitle = 'Submissions'; - return ; + return ; }; export default SubmittedIncidentsPage; diff --git a/site/gatsby-site/src/pages/apps/variants.js b/site/gatsby-site/src/pages/apps/variants.js index 03161eba4d..8b1e6186a2 100644 --- a/site/gatsby-site/src/pages/apps/variants.js +++ b/site/gatsby-site/src/pages/apps/variants.js @@ -5,7 +5,7 @@ import { Spinner } from 'flowbite-react'; import VariantsTable from '../../components/variants/VariantsTable'; import { FIND_VARIANTS } from '../../graphql/variants'; import { FIND_INCIDENTS } from '../../graphql/incidents'; -import AiidHead from '../../components/AiidHead'; +import HeadContent from '../../components/HeadContent'; import ListSkeleton from 'elements/Skeletons/List'; import { getVariantStatus, isCompleteReport } from '../../utils/variants'; @@ -102,5 +102,5 @@ export const Head = (props) => { const metaTitle = t('Variants'); - return ; + return ; }; diff --git a/site/gatsby-site/src/pages/blog/index.js b/site/gatsby-site/src/pages/blog/index.js index dcdab14d17..f4846571a2 100644 --- a/site/gatsby-site/src/pages/blog/index.js +++ b/site/gatsby-site/src/pages/blog/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import PostsListing from 'components/blog/PostsListing'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { useTranslation } from 'react-i18next'; const BlogPage = (props) => { @@ -23,7 +23,7 @@ export const Head = (props) => { const { t } = useTranslation(); return ( - { const { t } = useTranslation(); return ( - { const { t } = useTranslation(); return ( - { const metaTitle = 'CSET Charts'; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/flagged.js b/site/gatsby-site/src/pages/summaries/flagged.js index b6508ead5d..eff1ca34fd 100644 --- a/site/gatsby-site/src/pages/summaries/flagged.js +++ b/site/gatsby-site/src/pages/summaries/flagged.js @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { graphql } from 'gatsby'; const ReportList = ({ report }) => ( @@ -63,7 +63,7 @@ export const Head = (props) => { const metaTitle = 'Incident List'; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidents.js b/site/gatsby-site/src/pages/summaries/incidents.js index 4bc7d900f9..9046b75418 100644 --- a/site/gatsby-site/src/pages/summaries/incidents.js +++ b/site/gatsby-site/src/pages/summaries/incidents.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { graphql } from 'gatsby'; import Link from 'components/ui/Link'; import { hasVariantData } from 'utils/variants'; @@ -130,7 +130,7 @@ export const Head = (props) => { const metaTitle = t('Incident List', { ns: 'incidents' }); - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js index ed9421ed6e..aa5a59e84d 100644 --- a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js +++ b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import MultiLineChart from 'components/visualizations/MultiLineChart'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { graphql } from 'gatsby'; import { TextInput, Label } from 'flowbite-react'; import { format } from 'date-fns'; @@ -122,7 +122,7 @@ export const Head = (props) => { const metaTitle = 'Incidents Over Time'; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/leaderboard.js b/site/gatsby-site/src/pages/summaries/leaderboard.js index ee103d57af..aa11d45f2f 100644 --- a/site/gatsby-site/src/pages/summaries/leaderboard.js +++ b/site/gatsby-site/src/pages/summaries/leaderboard.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import Link from 'components/ui/Link'; import SubmittersLeaderboard from 'components/leaderboards/SubmittersLeaderboard'; @@ -42,5 +42,5 @@ export const Head = (props) => { const metaTitle = 'Submissions Leaderboard'; - return ; + return ; }; diff --git a/site/gatsby-site/src/pages/taxonomies.js b/site/gatsby-site/src/pages/taxonomies.js index 7944d064bc..04f9b38e7b 100644 --- a/site/gatsby-site/src/pages/taxonomies.js +++ b/site/gatsby-site/src/pages/taxonomies.js @@ -4,7 +4,7 @@ import TaxonomyGraphCarousel from '../../src/components/TaxonomyGraphCarousel.js import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; import { Trans, useTranslation } from 'react-i18next'; import TranslationBadge from 'components/i18n/TranslationBadge'; -import AiidHead from 'components/AiidHead.js'; +import HeadContent from 'components/HeadContent.js'; export default function Taxonomies({ data }) { const { t } = useTranslation(); @@ -82,7 +82,7 @@ export const Head = (props) => { const metaDescription = t('This is the list of taxonomies supported in AIID'); return ( - { const metaTitle = 'Database Backups and Snapshots'; - return ; + return ; }; export default Backups; diff --git a/site/gatsby-site/src/templates/blogPost.js b/site/gatsby-site/src/templates/blogPost.js index 986d4de8c9..fb03e14322 100644 --- a/site/gatsby-site/src/templates/blogPost.js +++ b/site/gatsby-site/src/templates/blogPost.js @@ -1,7 +1,7 @@ import React from 'react'; import { graphql } from 'gatsby'; import PrismicBlogPost from 'components/blog/PrismicBlogPost'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; export default function BlogPost(props) { const post = props?.data?.post; @@ -13,7 +13,7 @@ export const Head = (props) => { const post = props?.data?.post; return ( - { const canonicalUrl = getCanonicalUrl(true_incident_number); - return ; + return ; }; export default IncidentCite; diff --git a/site/gatsby-site/src/templates/cite.js b/site/gatsby-site/src/templates/cite.js index 0e18ab8e62..843cf6fe3a 100644 --- a/site/gatsby-site/src/templates/cite.js +++ b/site/gatsby-site/src/templates/cite.js @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { CloudinaryImage } from '@cloudinary/base'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; import { graphql } from 'gatsby'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { getTranslatedReports, sortIncidentsByDatePublished } from 'utils/cite'; import { computeEntities, RESPONSE_TAG } from 'utils/entities'; import config from '../../config'; @@ -156,7 +156,7 @@ export const Head = (props) => { const metaImage = image.createCloudinaryURL(); - return ; + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/templates/doc.js b/site/gatsby-site/src/templates/doc.js index 63c32f4137..a11f9edfad 100644 --- a/site/gatsby-site/src/templates/doc.js +++ b/site/gatsby-site/src/templates/doc.js @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { graphql, Link } from 'gatsby'; import { MDXProvider } from '@mdx-js/react'; import Components from 'components/ui/MdxComponents'; @@ -61,7 +61,7 @@ export const Head = (props) => { const metaDescription = mdx.frontmatter.metaDescription; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/entities.js b/site/gatsby-site/src/templates/entities.js index 6d6adfca2c..7e3907ca8f 100644 --- a/site/gatsby-site/src/templates/entities.js +++ b/site/gatsby-site/src/templates/entities.js @@ -3,7 +3,7 @@ import { graphql } from 'gatsby'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { makeEntitiesHash, makeIncidentsHash } from 'utils/entities'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const incidentFields = [ 'incidentsAsBoth', @@ -75,7 +75,7 @@ export const Head = (props) => { const canonicalUrl = 'https://incidentdatabase.ai/entities'; - return ; + return ; }; export const query = graphql` diff --git a/site/gatsby-site/src/templates/entity.js b/site/gatsby-site/src/templates/entity.js index 0e0427241b..0859ebe6ba 100644 --- a/site/gatsby-site/src/templates/entity.js +++ b/site/gatsby-site/src/templates/entity.js @@ -8,7 +8,7 @@ import useToastContext, { SEVERITY } from '../hooks/useToast'; import React, { useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { computeEntities, makeEntitiesHash, makeIncidentsHash } from 'utils/entities'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import useLocalizePath from 'components/i18n/useLocalizePath'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faEnvelope } from '@fortawesome/free-solid-svg-icons'; @@ -296,7 +296,7 @@ export const Head = (props) => { const metaTitle = 'Entity: ' + name; - return ; + return ; }; function UnsubscribeButton({ diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index 74f01368b6..ba878dc59c 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -16,7 +16,7 @@ import { useLocalization } from 'plugins/gatsby-theme-i18n'; import Container from '../elements/Container'; import config from '../../config'; import PostPreviewNew from 'components/blog/PrismicPostPreview'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; const LandingPage = (props) => { const { data } = props; @@ -177,7 +177,7 @@ export function Head({ location }) { return ( <> - { } return ( - { const metaDescription = doc?.data?.metadescription; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/report.js b/site/gatsby-site/src/templates/report.js index 7d8690c13d..62e1a6cc0f 100644 --- a/site/gatsby-site/src/templates/report.js +++ b/site/gatsby-site/src/templates/report.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import { Trans, useTranslation } from 'react-i18next'; import Container from '../elements/Container'; import SocialShareButtons from '../components/ui/SocialShareButtons'; @@ -88,7 +88,7 @@ export const Head = (props) => { const metaTitle = `Report ${report.report_number}`; return ( - { if (!props || !props.pageContext || !props.data) { @@ -20,7 +20,7 @@ export const Head = (props) => { const metaTitle = `${namespace} Charts`; - return ; + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/tsneVisualizationPage.js b/site/gatsby-site/src/templates/tsneVisualizationPage.js index 8fe72c85ec..75562ab314 100644 --- a/site/gatsby-site/src/templates/tsneVisualizationPage.js +++ b/site/gatsby-site/src/templates/tsneVisualizationPage.js @@ -1,5 +1,5 @@ import React from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import TsneVisualization from 'components/cite/TsneVisualization'; import { Trans, useTranslation } from 'react-i18next'; import { LocalizedLink } from 'plugins/gatsby-theme-i18n'; @@ -65,7 +65,7 @@ export const Head = (props) => { const metaDescription = t('Spatial Visualization'); - return ; + return ; }; export default TsneVisulizationPage; diff --git a/site/gatsby-site/src/templates/wordcounts.js b/site/gatsby-site/src/templates/wordcounts.js index a7913a61e8..d87e2dfb4a 100644 --- a/site/gatsby-site/src/templates/wordcounts.js +++ b/site/gatsby-site/src/templates/wordcounts.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import AiidHead from 'components/AiidHead'; +import HeadContent from 'components/HeadContent'; import ReactWordcloud from 'react-d3-cloud'; import Link from 'components/ui/Link'; @@ -79,7 +79,7 @@ export const Head = (props) => { const metaTitle = 'Word Counts'; - return ; + return ; }; export default WordCounts; From 0e9c2b3e943970e7d0bd5e7b82ef1c7ae3721c7c Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 26 Feb 2024 10:06:33 -0300 Subject: [PATCH 24/28] Remove unecessary useEffects and only use metaTitle for og --- .../gatsby-site/src/components/HeadContent.js | 47 ++++++++++++++----- .../src/components/blog/PostsListing.js | 35 ++++++-------- site/gatsby-site/src/templates/landingPage.js | 27 +++++------ 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/site/gatsby-site/src/components/HeadContent.js b/site/gatsby-site/src/components/HeadContent.js index d9c2bf31d2..b1b6bf023a 100644 --- a/site/gatsby-site/src/components/HeadContent.js +++ b/site/gatsby-site/src/components/HeadContent.js @@ -4,11 +4,10 @@ import config from '../../config'; const HeadContent = ({ children, metaTitle = null, - metaDescription = metaTitle, + metaDescription = null, path, metaImage = null, metaType = 'website', - title = null, }) => { const twitter = config.siteMetadata.twitterAccount; @@ -18,21 +17,43 @@ const HeadContent = ({ return ( <> - {title ? {title} : metaTitle ? {metaTitle} : <>} - {metaTitle && } - {metaTitle && } - {metaDescription && } - {metaDescription && } - {metaImage && } - {metaImage && } + {metaTitle && ( + <> + {metaTitle} + + + + )} + + {metaDescription && ( + <> + + + + )} + + {metaImage && ( + <> + + + + )} - {twitter && } - {twitter && } + {twitter && ( + <> + + + + )} - {canonicalUrl && } - {canonicalUrl && } + {canonicalUrl && ( + <> + + + + )} {config.siteMetadata.favicon && ( diff --git a/site/gatsby-site/src/components/blog/PostsListing.js b/site/gatsby-site/src/components/blog/PostsListing.js index 14c4b77f7c..7e5803097b 100644 --- a/site/gatsby-site/src/components/blog/PostsListing.js +++ b/site/gatsby-site/src/components/blog/PostsListing.js @@ -1,31 +1,26 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import PostPreview from './PostPreview'; import PrismicPostPreview from './PrismicPostPreview'; export default function PostsListing({ posts, mdxBlogPosts }) { - const [sortedPosts, setSortedPosts] = useState([]); + let sortedPosts = []; - useEffect(() => { - // Add an mdx field to each object and flatten the structure - const mdxBlogPostsWithFlag = mdxBlogPosts.map((post) => ({ - ...post, - date: post.frontmatter.date, - mdx: true, - })); + // Add an mdx field to each object and flatten the structure + const mdxBlogPostsWithFlag = mdxBlogPosts.map((post) => ({ + ...post, + date: post.frontmatter.date, + mdx: true, + })); - const postsWithFlag = posts.map((post) => ({ - ...post, - date: post.node.data.date, - mdx: false, - })); + const postsWithFlag = posts.map((post) => ({ + ...post, + date: post.node.data.date, + mdx: false, + })); - const mergedPosts = [...mdxBlogPostsWithFlag, ...postsWithFlag]; + const mergedPosts = [...mdxBlogPostsWithFlag, ...postsWithFlag]; - const sortedPosts = mergedPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); - - setSortedPosts(sortedPosts); - }), - [posts, mdxBlogPosts]; + sortedPosts = mergedPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); return ( <> diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index ba878dc59c..eb4251b2e0 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import Featured from 'components/landing/Featured'; import Leaderboards from 'components/landing/Leaderboards'; import Blog from 'components/landing/Blog'; @@ -25,22 +25,21 @@ const LandingPage = (props) => { const { latestReportNumbers } = props.pageContext; - const [latestBlogPost, setLatestBlogPost] = useState(null); + // const [latestBlogPost, setLatestBlogPost] = useState(null); + let latestBlogPost = null; - useEffect(() => { - if (!latestPostOld || latestPostOld.nodes.length === 0) { - setLatestBlogPost(latestPrismicPost); - } else if (!latestPrismicPost || latestPrismicPost.nodes.length === 0) { - setLatestBlogPost(latestPostOld); - } else { - const mdxDate = new Date(latestPostOld?.nodes[0]?.frontmatter?.date); + if (!latestPostOld || latestPostOld.nodes.length === 0) { + latestBlogPost = latestPrismicPost; + } else if (!latestPrismicPost || latestPrismicPost.nodes.length === 0) { + latestBlogPost = latestPostOld; + } else { + const mdxDate = new Date(latestPostOld?.nodes[0]?.frontmatter?.date); - const prismicDate = new Date(latestPrismicPost?.nodes[0]?.data.date); + const prismicDate = new Date(latestPrismicPost?.nodes[0]?.data.date); - // Display prismic post if it's the latest post or if it's newer than the latest mdx post - setLatestBlogPost(mdxDate > prismicDate ? latestPostOld : latestPrismicPost); - } - }, [latestPostOld, latestPrismicPost, latestReportIncidents]); + // Display prismic post if it's the latest post or if it's newer than the latest mdx post + latestBlogPost = mdxDate > prismicDate ? latestPostOld : latestPrismicPost; + } let { sponsors } = props.pageContext; From 3173ecb8da8e538b6647a96d2b54b86a943cc855 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 26 Feb 2024 10:51:55 -0300 Subject: [PATCH 25/28] remove commented code --- site/gatsby-site/src/templates/landingPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/site/gatsby-site/src/templates/landingPage.js b/site/gatsby-site/src/templates/landingPage.js index eb4251b2e0..fe9bf9197d 100644 --- a/site/gatsby-site/src/templates/landingPage.js +++ b/site/gatsby-site/src/templates/landingPage.js @@ -25,7 +25,6 @@ const LandingPage = (props) => { const { latestReportNumbers } = props.pageContext; - // const [latestBlogPost, setLatestBlogPost] = useState(null); let latestBlogPost = null; if (!latestPostOld || latestPostOld.nodes.length === 0) { From f90eaa396e6e43a59d1d4444916b3d1a47b0c718 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 11 Mar 2024 11:30:59 -0300 Subject: [PATCH 26/28] Add missing metaDescriptions --- site/gatsby-site/i18n/locales/en/translation.json | 2 +- site/gatsby-site/i18n/locales/es/incidents.json | 3 ++- site/gatsby-site/i18n/locales/es/submit.json | 3 ++- site/gatsby-site/i18n/locales/es/translation.json | 9 ++++++++- site/gatsby-site/i18n/locales/es/variants.json | 3 ++- site/gatsby-site/i18n/locales/fr/incidents.json | 3 ++- site/gatsby-site/i18n/locales/fr/submit.json | 3 ++- site/gatsby-site/i18n/locales/fr/translation.json | 9 ++++++++- site/gatsby-site/i18n/locales/fr/variants.json | 3 ++- site/gatsby-site/src/pages/404.js | 6 +++++- site/gatsby-site/src/pages/account.js | 8 +++++++- site/gatsby-site/src/pages/admin/index.js | 4 +++- site/gatsby-site/src/pages/api-spec.js | 4 ++++ site/gatsby-site/src/pages/apps/checklists.js | 8 +++++++- site/gatsby-site/src/pages/apps/classifications.js | 8 +++++++- .../{mongodbAiidprodIncidents.incident_id}.js | 2 +- site/gatsby-site/src/pages/apps/newsdigest.js | 6 +++++- site/gatsby-site/src/pages/apps/reports.js | 4 +++- site/gatsby-site/src/pages/apps/submit.js | 6 +++++- site/gatsby-site/src/pages/apps/submitted.js | 4 +++- site/gatsby-site/src/pages/apps/variants.js | 4 +++- site/gatsby-site/src/pages/summaries/cset-charts.js | 9 ++++++++- site/gatsby-site/src/pages/summaries/flagged.js | 4 +++- site/gatsby-site/src/pages/summaries/incidents.js | 6 +++++- .../src/pages/summaries/incidentsOverTime.js | 11 ++++++++++- site/gatsby-site/src/pages/summaries/leaderboard.js | 4 +++- site/gatsby-site/src/templates/entity.js | 4 +++- site/gatsby-site/src/templates/taxonomy.js | 9 ++++++++- site/gatsby-site/src/templates/wordcounts.js | 4 +++- 29 files changed, 125 insertions(+), 28 deletions(-) diff --git a/site/gatsby-site/i18n/locales/en/translation.json b/site/gatsby-site/i18n/locales/en/translation.json index 1b813088be..1a4fc65e8c 100644 --- a/site/gatsby-site/i18n/locales/en/translation.json +++ b/site/gatsby-site/i18n/locales/en/translation.json @@ -1,5 +1,5 @@ { "csetCharts": "The CSET AI Harm Taxonomy for AIID is the second edition of the CSET incident taxonomy. It characterizes the harms, entities, and technologies involved in AI incidents and the circumstances of their occurrence. The charts below show select fields from the CSET AI Harm Taxonomy for AIID. Details about each field can be found <1>here. However, brief descriptions of the field are provided above each chart.", "csetChartDeveloped": "CSET has developed specific definitions for the underlined phrases that may differ from other organizations’ definitions. As a result, other organizations may make different assessments on whether any particular AI incident is (or is not) AI harm. Details about CSET’s definitions for AI harm can be found <1>here.", - "csetChartMail": "Every incident is independently classified by two CSET annotators. Annotations are peer-reviewed and finally randomly selected for quality control ahead of publication. Despite this rigorous process, mistakes do happen, and readers are invited to <1>report any errors they might discover while browsing." + "csetChartMail": "Every incident is independently classified by two CSET annotators. Annotations are peer-reviewed and finally randomly selected for quality control ahead of publication. Despite this rigorous process, mistakes do happen, and readers are invited to <1>report any errors they might discover while browsing." } diff --git a/site/gatsby-site/i18n/locales/es/incidents.json b/site/gatsby-site/i18n/locales/es/incidents.json index bc378f1f03..e832964ac9 100644 --- a/site/gatsby-site/i18n/locales/es/incidents.json +++ b/site/gatsby-site/i18n/locales/es/incidents.json @@ -3,5 +3,6 @@ "This is a simple numeric listing of all incidents and their reports within the database. If you would like to explore the contents of the reports, you should work through the<1> Discover app.": "Se trata de una lista numérica simple de todos los incidentes y sus reportes dentro de la base de datos. Si desea explorar el contenido de los reportes, debe navegar a través de<1> Descubrir Incidentes.", "Sort by incident ID": "Ordenar por ID de incidente", "ascending": "ascendente", - "descending": "descendente" + "descending": "descendente", + "Summary of all the incidents present in the database": "Resumen de todos los incidentes presentes en la base de datos" } \ No newline at end of file diff --git a/site/gatsby-site/i18n/locales/es/submit.json b/site/gatsby-site/i18n/locales/es/submit.json index b905812ac6..0b7883ad82 100644 --- a/site/gatsby-site/i18n/locales/es/submit.json +++ b/site/gatsby-site/i18n/locales/es/submit.json @@ -58,5 +58,6 @@ "Progress saved!": "¡Progreso guardado!", "Your changes are saved. You can continue filling out the report or come back later.": "Sus cambios se están guardando. Puede continuar completando el reporte o volver más tarde.", "Clear Form": "Limpiar Formulario", - "Saving changes...": "Guardando cambios..." + "Saving changes...": "Guardando cambios...", + "Submit a new incident report to the Artificial Intelligence Incident Database": "Enviar un nuevo informe de incidente a la Base de Datos de Incidentes de Inteligencia Artificial" } diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index bb06e4009a..fd3657840c 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -298,5 +298,12 @@ "Sign up for an account": "Regístrate para obtener una cuenta", "AIID - Sign Up": "AIID - Registrarse", "AIID - Login": "AIID - Iniciar sesión", - "Login to your account": "Inicia sesión en tu cuenta" + "Login to your account": "Inicia sesión en tu cuenta", + "Related News Digest": "Resumen de noticias relacionadas", + "This summary features AI-related news, identified and matched to our database via NLP for textual similarity, including potential incidents and highlighted harm keywords.": "Este resumen presenta noticias relacionadas con la IA, identificadas y emparejadas con nuestra base de datos mediante PNL para similitud textual, incluyendo incidentes potenciales y palabras clave de daño destacadas.", + "Website's list of incidents and reports.": "Lista de incidentes e informes del sitio web.", + "Incidents Over Time": "Incidentes a lo largo del tiempo", + "View how the number of incidents and reports has changed over time.": "Ver cómo ha cambiado el número de incidentes e informes a lo largo del tiempo.", + "Leaderboard of top submitters, authors, and domains by count.": "Ranking de los principales remitentes, autores y dominios por cantidad.", + "Submissions Leaderboard": "Ranking de envíos" } diff --git a/site/gatsby-site/i18n/locales/es/variants.json b/site/gatsby-site/i18n/locales/es/variants.json index cc41272d8a..bfb96b9b7a 100644 --- a/site/gatsby-site/i18n/locales/es/variants.json +++ b/site/gatsby-site/i18n/locales/es/variants.json @@ -33,5 +33,6 @@ "Inputs / Outputs": "Salidas / Entradas", "The sequence of data inputs into the intelligent system and outputs produced by the system involved in the incident. For a chatbot, this will generally present a back and forth between a human and the chatbot's responses.": "La secuencia de entradas de datos en el sistema inteligente y salidas producidas por el sistema involucrado en el incidente. Para un chatbot, esto generalmente presentará un ida y vuelta entre las respuestas de un ser humano y las del chatbot.", "Add Row": "Agregar fila", - "Delete Row": "Borrar fila" + "Delete Row": "Borrar fila", + "View all the variants in the database.": "Ver todas las variantes en la base de datos." } diff --git a/site/gatsby-site/i18n/locales/fr/incidents.json b/site/gatsby-site/i18n/locales/fr/incidents.json index e9a40cca4c..eee7507851 100644 --- a/site/gatsby-site/i18n/locales/fr/incidents.json +++ b/site/gatsby-site/i18n/locales/fr/incidents.json @@ -3,5 +3,6 @@ "This is a simple numeric listing of all incidents and their reports within the database. If you would like to explore the contents of the reports, you should work through the<1> Discover app.": "Il s'agit d'une simple liste numérique de tous les incidents et de leurs rapports dans la base de données. Si vous souhaitez explorer le contenu des rapports, vous devez parcourir <1> Découvrir les incidents.", "Sort by incident ID": "Trier par ID d'incident", "ascending": "ascendant", - "descending": "descendant" + "descending": "descendant", + "Summary of all the incidents present in the database": "Résumé de tous les incidents présents dans la base de données" } \ No newline at end of file diff --git a/site/gatsby-site/i18n/locales/fr/submit.json b/site/gatsby-site/i18n/locales/fr/submit.json index 0d20f35862..5b15c139b4 100644 --- a/site/gatsby-site/i18n/locales/fr/submit.json +++ b/site/gatsby-site/i18n/locales/fr/submit.json @@ -55,5 +55,6 @@ "Progress saved!": "Progrès sauvegardé !", "Your changes are saved. You can continue filling out the report or come back later.": "Vos modifications sont en cours d'enregistrement. Vous pouvez continuer à remplir le rapport ou revenir plus tard.", "Clear Form": "Effacer le formulaire", - "Saving changes...": "Enregistrement des modifications..." + "Saving changes...": "Enregistrement des modifications...", + "Submit a new incident report to the Artificial Intelligence Incident Database.": "Soumettre un nouveau rapport d'incident à la base de données des incidents d'intelligence artificielle." } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index c248280e79..d1ccc20693 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -286,5 +286,12 @@ "Sign up for an account": "Créer un compte", "AIID - Sign Up": "AIID - Créer un compte", "AIID - Login": "AIID - Se connecter", - "Login to your account": "Connectez-vous à votre compte" + "Login to your account": "Connectez-vous à votre compte", + "Related News Digest": "Résumé des actualités connexes", + "This summary features AI-related news, identified and matched to our database via NLP for textual similarity, including potential incidents and highlighted harm keywords.": "Ce résumé présente des actualités liées à l'IA, identifiées et appariées à notre base de données via le TAL pour une similarité textuelle, incluant des incidents potentiels et des mots-clés de dommage mis en évidence.", + "Website's list of incidents and reports.": "Liste des incidents et des rapports du site Web.", + "Incidents Over Time": "Incidents au fil du temps", + "View how the number of incidents and reports has changed over time.": "Voir comment le nombre d'incidents et de rapports a changé au fil du temps.", + "Leaderboard of top submitters, authors, and domains by count.": "Classement des meilleurs soumissionnaires, auteurs et domaines par nombre.", + "Submissions Leaderboard": "Classement des soumissions" } diff --git a/site/gatsby-site/i18n/locales/fr/variants.json b/site/gatsby-site/i18n/locales/fr/variants.json index 0fffdf2e13..70f37da2be 100644 --- a/site/gatsby-site/i18n/locales/fr/variants.json +++ b/site/gatsby-site/i18n/locales/fr/variants.json @@ -33,5 +33,6 @@ "Inputs / Outputs": "Entrées / Sorties", "The sequence of data inputs into the intelligent system and outputs produced by the system involved in the incident. For a chatbot, this will generally present a back and forth between a human and the chatbot's responses.": "La séquence des entrées de données dans le système intelligent et des sorties produites par le système impliqué dans l'incident. Pour un chatbot, cela présentera généralement un va-et-vient entre un humain et les réponses du chatbot.", "Add Row": "Ajouter une ligne", - "Delete Row": "Supprimer la ligne" + "Delete Row": "Supprimer la ligne", + "View all the variants in the database.": "Voir toutes les variantes dans la base de données." } diff --git a/site/gatsby-site/src/pages/404.js b/site/gatsby-site/src/pages/404.js index 359bee0369..202ca1974c 100644 --- a/site/gatsby-site/src/pages/404.js +++ b/site/gatsby-site/src/pages/404.js @@ -13,7 +13,11 @@ const Default404 = () => { }; export const Head = (props) => ( - + ); export default Default404; diff --git a/site/gatsby-site/src/pages/account.js b/site/gatsby-site/src/pages/account.js index 7f306d57e3..7b53e6212f 100644 --- a/site/gatsby-site/src/pages/account.js +++ b/site/gatsby-site/src/pages/account.js @@ -50,7 +50,13 @@ const Account = () => { export const Head = (props) => { const { t } = useTranslation(['account']); - return ; + return ( + + ); }; export default Account; diff --git a/site/gatsby-site/src/pages/admin/index.js b/site/gatsby-site/src/pages/admin/index.js index efe69b7c9c..6a1f9a79b0 100644 --- a/site/gatsby-site/src/pages/admin/index.js +++ b/site/gatsby-site/src/pages/admin/index.js @@ -44,7 +44,9 @@ export const Head = (props) => { location: { pathname }, } = props; - return ; + return ( + + ); }; export default AdminPage; diff --git a/site/gatsby-site/src/pages/api-spec.js b/site/gatsby-site/src/pages/api-spec.js index e3e1433ffa..f094dd83a2 100644 --- a/site/gatsby-site/src/pages/api-spec.js +++ b/site/gatsby-site/src/pages/api-spec.js @@ -1,3 +1,4 @@ +import HeadContent from 'components/HeadContent'; import React, { useEffect } from 'react'; const ApiSpec = () => { @@ -16,6 +17,8 @@ const ApiSpec = () => { }; export const Head = () => { + const metaTitle = 'API Spec'; + return ( <> ; @@ -23,6 +26,7 @@ export const Head = () => { src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossOrigin="anonymous" /> + ); }; diff --git a/site/gatsby-site/src/pages/apps/checklists.js b/site/gatsby-site/src/pages/apps/checklists.js index 9c33193919..562e0877a7 100644 --- a/site/gatsby-site/src/pages/apps/checklists.js +++ b/site/gatsby-site/src/pages/apps/checklists.js @@ -234,7 +234,13 @@ export const Head = (props) => { const { t } = useTranslation(); - return ; + return ( + + ); }; export default ChecklistsPage; diff --git a/site/gatsby-site/src/pages/apps/classifications.js b/site/gatsby-site/src/pages/apps/classifications.js index 74d4a45407..905ad42e01 100644 --- a/site/gatsby-site/src/pages/apps/classifications.js +++ b/site/gatsby-site/src/pages/apps/classifications.js @@ -572,5 +572,11 @@ export const Head = (props) => { location: { pathname }, } = props; - return ; + return ( + + ); }; diff --git a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js index 00088c1e10..672e4f2f19 100644 --- a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js +++ b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js @@ -90,7 +90,7 @@ export const Head = (props) => { const metaTitle = 'CSET Tool'; - return ; + return ; }; export default ToolPage; diff --git a/site/gatsby-site/src/pages/apps/newsdigest.js b/site/gatsby-site/src/pages/apps/newsdigest.js index d17169d91f..5a750a9547 100644 --- a/site/gatsby-site/src/pages/apps/newsdigest.js +++ b/site/gatsby-site/src/pages/apps/newsdigest.js @@ -493,5 +493,9 @@ export const Head = (props) => { const title = t('Related News Digest'); - return ; + const metaDescription = t( + 'This summary features AI-related news, identified and matched to our database via NLP for textual similarity, including potential incidents and highlighted harm keywords.' + ); + + return ; }; diff --git a/site/gatsby-site/src/pages/apps/reports.js b/site/gatsby-site/src/pages/apps/reports.js index 8f526edafe..749c18e26d 100644 --- a/site/gatsby-site/src/pages/apps/reports.js +++ b/site/gatsby-site/src/pages/apps/reports.js @@ -234,5 +234,7 @@ export const Head = (props) => { const metaTitle = t('Incident List'); - return ; + const metaDescription = t("Website's list of incidents and reports."); + + return ; }; diff --git a/site/gatsby-site/src/pages/apps/submit.js b/site/gatsby-site/src/pages/apps/submit.js index 0863c706e8..d057632659 100644 --- a/site/gatsby-site/src/pages/apps/submit.js +++ b/site/gatsby-site/src/pages/apps/submit.js @@ -20,7 +20,11 @@ export const Head = (props) => { const metaTitle = t('New Incident Report'); - return ; + const metaDescription = t( + 'Submit a new incident report to the Artificial Intelligence Incident Database' + ); + + return ; }; export default SubmitPage; diff --git a/site/gatsby-site/src/pages/apps/submitted.js b/site/gatsby-site/src/pages/apps/submitted.js index f2cde2303e..fe670e9d87 100644 --- a/site/gatsby-site/src/pages/apps/submitted.js +++ b/site/gatsby-site/src/pages/apps/submitted.js @@ -195,7 +195,9 @@ export const Head = (props) => { const metaTitle = 'Submissions'; - return ; + const metaDescription = 'Submitted incidents and quick adds'; + + return ; }; export default SubmittedIncidentsPage; diff --git a/site/gatsby-site/src/pages/apps/variants.js b/site/gatsby-site/src/pages/apps/variants.js index 8b1e6186a2..cb4728872c 100644 --- a/site/gatsby-site/src/pages/apps/variants.js +++ b/site/gatsby-site/src/pages/apps/variants.js @@ -102,5 +102,7 @@ export const Head = (props) => { const metaTitle = t('Variants'); - return ; + const metaDescription = t('View all the variants in the database.'); + + return ; }; diff --git a/site/gatsby-site/src/pages/summaries/cset-charts.js b/site/gatsby-site/src/pages/summaries/cset-charts.js index 3eb0f40dc2..01abc7d51f 100644 --- a/site/gatsby-site/src/pages/summaries/cset-charts.js +++ b/site/gatsby-site/src/pages/summaries/cset-charts.js @@ -112,7 +112,14 @@ export const Head = (props) => { const metaTitle = 'CSET Charts'; - return ; + return ( + + ); }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/flagged.js b/site/gatsby-site/src/pages/summaries/flagged.js index eff1ca34fd..595802abd9 100644 --- a/site/gatsby-site/src/pages/summaries/flagged.js +++ b/site/gatsby-site/src/pages/summaries/flagged.js @@ -63,7 +63,9 @@ export const Head = (props) => { const metaTitle = 'Incident List'; - return ; + const metaDescription = 'Flagged Incident List'; + + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidents.js b/site/gatsby-site/src/pages/summaries/incidents.js index 9046b75418..2f6d981527 100644 --- a/site/gatsby-site/src/pages/summaries/incidents.js +++ b/site/gatsby-site/src/pages/summaries/incidents.js @@ -130,7 +130,11 @@ export const Head = (props) => { const metaTitle = t('Incident List', { ns: 'incidents' }); - return ; + const metaDescription = t('Summary of all the incidents present in the database', { + ns: 'incidents', + }); + + return ; }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js index aa5a59e84d..9bc63f50ae 100644 --- a/site/gatsby-site/src/pages/summaries/incidentsOverTime.js +++ b/site/gatsby-site/src/pages/summaries/incidentsOverTime.js @@ -122,7 +122,16 @@ export const Head = (props) => { const metaTitle = 'Incidents Over Time'; - return ; + const metaDescription = 'View how the number of incidents and reports has changed over time.'; + + return ( + + ); }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/pages/summaries/leaderboard.js b/site/gatsby-site/src/pages/summaries/leaderboard.js index aa11d45f2f..f9920523af 100644 --- a/site/gatsby-site/src/pages/summaries/leaderboard.js +++ b/site/gatsby-site/src/pages/summaries/leaderboard.js @@ -42,5 +42,7 @@ export const Head = (props) => { const metaTitle = 'Submissions Leaderboard'; - return ; + const metaDescription = 'Leaderboard of top submitters, authors, and domains by count.'; + + return ; }; diff --git a/site/gatsby-site/src/templates/entity.js b/site/gatsby-site/src/templates/entity.js index 0859ebe6ba..888d8aac59 100644 --- a/site/gatsby-site/src/templates/entity.js +++ b/site/gatsby-site/src/templates/entity.js @@ -296,7 +296,9 @@ export const Head = (props) => { const metaTitle = 'Entity: ' + name; - return ; + const metaDescription = 'Information about ' + name + ' and its involvement in AI incidents.'; + + return ; }; function UnsubscribeButton({ diff --git a/site/gatsby-site/src/templates/taxonomy.js b/site/gatsby-site/src/templates/taxonomy.js index 2ee15047e0..7f29e8316e 100644 --- a/site/gatsby-site/src/templates/taxonomy.js +++ b/site/gatsby-site/src/templates/taxonomy.js @@ -20,7 +20,14 @@ export const Head = (props) => { const metaTitle = `${namespace} Charts`; - return ; + return ( + + ); }; export const pageQuery = graphql` diff --git a/site/gatsby-site/src/templates/wordcounts.js b/site/gatsby-site/src/templates/wordcounts.js index d87e2dfb4a..703848186b 100644 --- a/site/gatsby-site/src/templates/wordcounts.js +++ b/site/gatsby-site/src/templates/wordcounts.js @@ -79,7 +79,9 @@ export const Head = (props) => { const metaTitle = 'Word Counts'; - return ; + const metaDescription = 'Word Counts from Incident Reports.'; + + return ; }; export default WordCounts; From 64f1a60f4380974f210338ba08c0af3e2b877023 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 11 Mar 2024 12:12:21 -0300 Subject: [PATCH 27/28] Add metaDescription to backup page --- site/gatsby-site/i18n/locales/es/translation.json | 4 +++- site/gatsby-site/i18n/locales/fr/translation.json | 4 +++- site/gatsby-site/src/templates/backups.js | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index fd3657840c..7ae4759fe7 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -305,5 +305,7 @@ "Incidents Over Time": "Incidentes a lo largo del tiempo", "View how the number of incidents and reports has changed over time.": "Ver cómo ha cambiado el número de incidentes e informes a lo largo del tiempo.", "Leaderboard of top submitters, authors, and domains by count.": "Ranking de los principales remitentes, autores y dominios por cantidad.", - "Submissions Leaderboard": "Ranking de envíos" + "Submissions Leaderboard": "Ranking de envíos", + "Database Backups and Snapshots": "Copias de seguridad y capturas de la base de datos", + "Find and download the latest Database Backups and snapshots": "Encuentra y descarga las últimas copias de seguridad y capturas de la base de datos" } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index d1ccc20693..f5cafc665b 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -293,5 +293,7 @@ "Incidents Over Time": "Incidents au fil du temps", "View how the number of incidents and reports has changed over time.": "Voir comment le nombre d'incidents et de rapports a changé au fil du temps.", "Leaderboard of top submitters, authors, and domains by count.": "Classement des meilleurs soumissionnaires, auteurs et domaines par nombre.", - "Submissions Leaderboard": "Classement des soumissions" + "Submissions Leaderboard": "Classement des soumissions", + "Database Backups and Snapshots": "Sauvegardes et instantanés de la base de données", + "Find and download the latest Database Backups and snapshots": "Trouver et télécharger les dernières sauvegardes et instantanés de la base de données" } diff --git a/site/gatsby-site/src/templates/backups.js b/site/gatsby-site/src/templates/backups.js index e8b0c480f9..b0a623b306 100644 --- a/site/gatsby-site/src/templates/backups.js +++ b/site/gatsby-site/src/templates/backups.js @@ -7,6 +7,7 @@ import Row from 'elements/Row'; import Col from 'elements/Col'; import { format } from 'date-fns'; import config from '../../config'; +import { useTranslation } from 'react-i18next'; const Backups = ({ pageContext }) => { const { backups } = pageContext; @@ -110,9 +111,13 @@ export const Head = (props) => { location: { pathname }, } = props; - const metaTitle = 'Database Backups and Snapshots'; + const { t } = useTranslation(); - return ; + const metaTitle = t('Database Backups and Snapshots'); + + const metaDescription = t('Find and download the latest Database Backups and snapshots'); + + return ; }; export default Backups; From 54c16ca851a2408bec9fc5c576982421dd4e0e11 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 3 Apr 2024 10:05:15 -0300 Subject: [PATCH 28/28] Fix null mdx in OG --- .../gatsby-site/page-creators/createBlogPages.js | 2 +- site/gatsby-site/src/templates/post.js | 8 +++++++- .../{blogPost.js => prismicBlogPost.js} | 16 ++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) rename site/gatsby-site/src/templates/{blogPost.js => prismicBlogPost.js} (77%) diff --git a/site/gatsby-site/page-creators/createBlogPages.js b/site/gatsby-site/page-creators/createBlogPages.js index 950795dd59..cf6218d7dd 100644 --- a/site/gatsby-site/page-creators/createBlogPages.js +++ b/site/gatsby-site/page-creators/createBlogPages.js @@ -73,7 +73,7 @@ const createBlogPages = async (graphql, createPage, { languages, reporter }) => createPage({ path: `/blog/${post.data.slug}`, - component: path.resolve('./src/templates/blogPost.js'), + component: path.resolve('./src/templates/prismicBlogPost.js'), context: { slug: post.data.slug, }, diff --git a/site/gatsby-site/src/templates/post.js b/site/gatsby-site/src/templates/post.js index cb2e0549b4..53edc94357 100644 --- a/site/gatsby-site/src/templates/post.js +++ b/site/gatsby-site/src/templates/post.js @@ -82,7 +82,13 @@ export default function Post(props) { var Author = ({ name }) => {name}; export const Head = (props) => { - const mdx = props?.data?.mdx; + let { + data: { mdx, enMdx }, // "mdx" is the translated version of the doc, "enMdx" is the English version + } = props; + + if (!mdx) { + mdx = enMdx; + } const metaTitle = mdx.frontmatter.metaTitle; diff --git a/site/gatsby-site/src/templates/blogPost.js b/site/gatsby-site/src/templates/prismicBlogPost.js similarity index 77% rename from site/gatsby-site/src/templates/blogPost.js rename to site/gatsby-site/src/templates/prismicBlogPost.js index fb03e14322..7cf98468eb 100644 --- a/site/gatsby-site/src/templates/blogPost.js +++ b/site/gatsby-site/src/templates/prismicBlogPost.js @@ -13,12 +13,16 @@ export const Head = (props) => { const post = props?.data?.post; return ( - + <> + {post && ( + + )} + ); };