Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions frontend/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button } from "@mui/material";
import makeStyles from "@mui/styles/makeStyles";
import React, { useContext, useEffect, useRef, useState } from "react";
import Head from "next/head";
import { IconButton } from "@mui/material";
import ArrowUpwardIcon from "@mui/icons-material/ArrowUpward";
import { apiRequest, getLocalePrefix } from "../public/lib/apiOperations";
Expand Down Expand Up @@ -149,8 +150,18 @@ export default function Index() {

const scrollToTop = () => window.scrollTo({ top: 0, behavior: "smooth" });

const schemaMarkup = {
"@context": "https://schema.org",
"@type": "WebSite",
name: "Climate Connect",
url: "https://climateconnect.earth/",
};

return (
<BrowseContext.Provider value={contextValues}>
<Head>
<script type="application/ld+json">{JSON.stringify(schemaMarkup)}</script>
</Head>
<WideLayout
/*TODO(unused) hideTitle */
fixedHeader
Expand Down
6 changes: 3 additions & 3 deletions frontend/pages/profiles/[profileUrl].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export default function ProfilePage({ profile, projects, organizations, ideas, p
<WideLayout
title={profile ? texts.persons_profile : texts.not_found}
description={
profile.name +
profile?.name +
" | " +
profile.info.location +
(profile.info.bio ? " | " + profile.info.bio : "")
profile?.info?.location +
(profile?.info?.bio ? " | " + profile?.info?.bio : "")
}
>
{profile ? (
Expand Down
10 changes: 8 additions & 2 deletions frontend/pages/projects/[projectId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import NextCookies from "next-cookies";
import React, { useContext, useEffect, useRef, useState } from "react";
import Cookies from "universal-cookie";
import ROLE_TYPES from "../../public/data/role_types";
import { apiRequest } from "../../public/lib/apiOperations";
import { apiRequest, getLocalePrefix } from "../../public/lib/apiOperations";
import { nullifyUndefinedValues } from "../../public/lib/profileOperations";
import getTexts from "../../public/texts/texts";
import UserContext from "../../src/components/context/UserContext";
Expand Down Expand Up @@ -70,6 +70,7 @@ const parseComments = (comments) => {
export async function getServerSideProps(ctx) {
const { auth_token } = NextCookies(ctx);
const projectUrl = encodeURI(ctx.query.projectId);

const [
project,
members,
Expand Down Expand Up @@ -224,7 +225,7 @@ export default function ProjectPage({
description={project?.short_description}
message={message?.message}
messageType={message?.messageType}
title={project ? project.name : texts.project + " " + texts.not_found}
title={project ? project?.name : texts.project + " " + texts.not_found}
subHeader={
!tinyScreen ? (
<HubsSubHeader hubs={hubs} subHeaderRef={hubsSubHeaderRef} onlyShowDropDown={true} />
Expand All @@ -233,6 +234,11 @@ export default function ProjectPage({
)
}
image={project ? getImageUrl(project.image) : undefined}
canonicalUrl={
project.url_slug
? `${process.env.BASE_URL + getLocalePrefix(locale)}/projects/${project?.url_slug}`
: ""
}
>
<BrowseContext.Provider value={contextValues}>
{project ? (
Expand Down
7 changes: 6 additions & 1 deletion frontend/pages/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ export default function Signin() {
};

return (
<Layout title={texts.log_in} isLoading={isLoading} messageType="error">
<Layout
title={texts.log_in}
isLoading={isLoading}
messageType="error"
canonicalUrl={`${process.env.BASE_URL + getLocalePrefix(locale) + "/signin"}`}
>
<Form
fields={fields}
messages={messages}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/layouts/LayoutWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function LayoutWrapper({
description,
image,
useFloodStdFont,
canonicalUrl,
}: any) {
const [snackbarProps, setSnackbarProps] = useState({
open: false,
Expand Down Expand Up @@ -159,6 +160,7 @@ export default function LayoutWrapper({
<meta property="og:type" content="website" />

<meta name="description" content={description ? description : defaultDescription} />
{canonicalUrl && <link rel="canonical" href={canonicalUrl} />}
</Head>
{/* If theme is falsy, slience the MUI console.warning for having an undefined theme */}
<ThemeProvider theme={theme}>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/layouts/WideLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Props = {
customFooterImage?: string;
isLocationHub?: boolean;
noHeader?: boolean;
canonicalUrl?: string;
};
//Wrapper layout component for pages where the content takes the whole width of the screen
export default function WideLayout({
Expand Down Expand Up @@ -94,6 +95,7 @@ export default function WideLayout({
hideDonationCampaign,
customFooterImage,
noHeader,
canonicalUrl,
}: Props) {
const classes = useStyles({ noSpaceBottom: noSpaceBottom, isStaticPage: isStaticPage });
const [alertOpen, setAlertOpen] = React.useState(true);
Expand Down Expand Up @@ -127,6 +129,7 @@ export default function WideLayout({
useFloodStdFont={useFloodStdFont}
theme={theme}
image={image}
canonicalUrl={canonicalUrl}
>
{!noHeader && (
<Header
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/layouts/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function Layout({
messageType,
isLoading,
isStaticPage,
canonicalUrl,
}: any) {
const classes = useStyles({ donationCampaignRunning: process.env.DONATION_CAMPAIGN_RUNNING });
const [hideAlertMessage, setHideAlertMessage] = React.useState(false);
Expand All @@ -43,8 +44,9 @@ export default function Layout({
setInitialMessageType("error");
}
}, []);

return (
<LayoutWrapper theme={theme} title={title}>
<LayoutWrapper theme={theme} title={title} canonicalUrl={canonicalUrl}>
<Header noSpacingBottom isStaticPage={isStaticPage} />
{<DonationCampaignInformation />}
{isLoading ? (
Expand Down