Skip to content

Commit

Permalink
fix: dynamic og tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Jadapema committed Jan 22, 2025
1 parent c10e1c1 commit bfc151b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/pages/dashboard/governance/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ProductDetailsPage() {
description="Discover the latest decentralized creations on Watchit. Powered by Web3 & AI."
url={`${GLOBAL_CONSTANTS.BASE_URL}/governance`}
>
<GovernanceDetailsView title="" />
<GovernanceDetailsView />
</OgMetaTags>
)
}
15 changes: 8 additions & 7 deletions src/pages/dashboard/publication/details.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Helmet } from 'react-helmet-async';
// routes
import { useParams, useRouter } from '@src/routes/hooks';
// sections
Expand All @@ -7,6 +6,8 @@ import Header from '@src/layouts/dashboard/header.tsx';
import { paths } from '@src/routes/paths.ts';

import HeaderContent from '@src/layouts/dashboard/header-content.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

// ----------------------------------------------------------------------

Expand All @@ -20,16 +21,16 @@ export default function ProductDetailsPage() {
};

return (
<>
<Helmet>
<title> Dashboard: Movie details</title>
</Helmet>

<OgMetaTags
title="Watchit: Discover Unique Publications"
description="Dive into the details of exciting publications. Experience cutting-edge content and support creators on Watchit, powered by Web3 and AI."
url={`${GLOBAL_CONSTANTS.BASE_URL}/publication/${id}`}
>
<Header>
<HeaderContent handleBack={handleBack} title="Movie details" />
</Header>

<PublicationDetailsView id={`${id}`} />
</>
</OgMetaTags>
);
}
15 changes: 8 additions & 7 deletions src/pages/dashboard/publication/new.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Helmet } from 'react-helmet-async';
// sections
import { PublicationCreateView } from '@src/sections/publication/view';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

// ----------------------------------------------------------------------

export default function MovieCreatePage() {
return (
<>
<Helmet>
<title> Dashboard: Create a new movie</title>
</Helmet>

<OgMetaTags
title="Watchit: Create New Content"
description="Unleash your creativity in Watchit Studio. Share your next big idea with powerful tools for metadata, subtitles, and more."
url={`${GLOBAL_CONSTANTS.BASE_URL}/publication/new`}
>
<PublicationCreateView />
</>
</OgMetaTags>
);
}
17 changes: 9 additions & 8 deletions src/pages/dashboard/publication/play.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Helmet } from 'react-helmet-async';
// sections
import { PublicationPlayView } from '@src/sections/publication/view';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';
import { useParams } from '@src/routes/hooks';

// ----------------------------------------------------------------------
Expand All @@ -10,12 +11,12 @@ export default function MovieCreatePage() {
const { id } = params;

return (
<>
<Helmet>
<title> Dashboard: Create a new movie</title>
</Helmet>

<PublicationPlayView id={id} publication={undefined} loading={false} />
</>
<OgMetaTags
title="Watchit: Stream Exclusive Content"
description="Enjoy decentralized streaming experiences on Watchit. Watch exclusive content and explore the future of video powered by Web3 and AI."
url={`${GLOBAL_CONSTANTS.BASE_URL}/publication/play/${id}`}
>
<PublicationPlayView publication={undefined} loading={false} />
</OgMetaTags>
);
}
10 changes: 8 additions & 2 deletions src/pages/dashboard/user/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { UserProfileView } from '@src/sections/user/view';
import { useParams } from '@src/routes/hooks';
import Header from '@src/layouts/dashboard/header.tsx';
import HeaderContent from '@src/layouts/dashboard/header-content.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

// ----------------------------------------------------------------------

Expand All @@ -11,12 +13,16 @@ export default function UserProfilePage() {
const { id } = params;

return (
<>
<OgMetaTags
title="Watchit: Explore Profiles"
description="Discover creators and their contributions on Watchit. Connect, explore, and support their journey in decentralized content powered by Web3 and AI."
url={`${GLOBAL_CONSTANTS.BASE_URL}/profile/${id}`}
>
<Header>
<HeaderContent title="Profile" />
</Header>

<UserProfileView id={id} />
</>
</OgMetaTags>
);
}
73 changes: 21 additions & 52 deletions src/sections/publication/view/publication-details-view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REACT IMPORTS
import { FC, PropsWithChildren, useEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

// MUI IMPORTS
import Box from '@mui/material/Box';
Expand Down Expand Up @@ -32,11 +32,7 @@ import { SubscribeProfileModal } from '@src/components/subscribe-profile-modal.t
import LoadingButton from '@mui/lab/LoadingButton';
import { useDispatch, useSelector } from 'react-redux';
import { openLoginModal } from '@redux/auth';
// @ts-ignore
import { ReadResult } from '@lens-protocol/react/dist/declarations/src/helpers/reads';
import { appId, PublicationType, usePublications } from '@lens-protocol/react-web';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';

const MAX_LINES = 5;

Expand Down Expand Up @@ -120,36 +116,32 @@ export default function PublicationDetailsView({ id }: Props) {
const filteredPublications = publications?.filter((publication) => publication.id !== id) ?? [];

if (loading || accessLoading) return (
<PublicationDetailsTags image={getMediaUri(getPosterCid())} publicationId={id} title={data?.metadata?.title ?? 'publication'}>
<LoadingScreen />
</PublicationDetailsTags>
<LoadingScreen />
);

if (data.isHidden)
return (
<PublicationDetailsTags image={getMediaUri(getPosterCid())} publicationId={id} title={data?.metadata?.title ?? 'publication'}>
<Box sx={{ padding: 2 }}>
<Typography
sx={{
height: '20rem',
textAlign: 'center',
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontWeight: 'bold',
background: '#2b2d31',
borderRadius: '1rem',
}}
>
Publication is hidden
</Typography>
</Box>
</PublicationDetailsTags>
<Box sx={{ padding: 2 }}>
<Typography
sx={{
height: '20rem',
textAlign: 'center',
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontWeight: 'bold',
background: '#2b2d31',
borderRadius: '1rem',
}}
>
Publication is hidden
</Typography>
</Box>
);

return (
<PublicationDetailsTags image={getMediaUri(getPosterCid())} publicationId={id} title={data?.metadata?.title ?? 'publication'}>
<>
<Box
sx={{
flexDirection: {
Expand Down Expand Up @@ -370,29 +362,6 @@ export default function PublicationDetailsView({ id }: Props) {
onSubscribe={onSubscribe}
profile={data?.by}
/>
</PublicationDetailsTags>
</>
);
}

interface PublicationDetailsTagsProps {
title: string
image: string
publicationId: string
}

const PublicationDetailsTags: FC<PropsWithChildren<PublicationDetailsTagsProps>> = ({ title, publicationId, image: customImage, children }) => {
// OG META TAGS DATA
const metaTitle = `Watchit: ${title}`
const description = 'Check out this amazing publication on Watchit, where content meets Web3 & AI.'
const image = customImage ?? GLOBAL_CONSTANTS.LOGO_URL
const url = `${GLOBAL_CONSTANTS.BASE_URL}/publication/${publicationId}`

return <OgMetaTags
title={metaTitle}
description={description}
image={image}
url={url}
>
{children}
</OgMetaTags>
}
32 changes: 4 additions & 28 deletions src/sections/user/view/user-profile-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren, useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
// @mui
import Tab from '@mui/material/Tab';
import Container from '@mui/material/Container';
Expand All @@ -22,8 +22,6 @@ import { RootState } from '@src/redux/store';
import { setFollowers, setFollowings } from '@redux/followers';
import ProfileReferrals from "@src/sections/user/profile-referrals.tsx";
import useReferrals from "@src/hooks/use-referrals.ts";
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';

// ----------------------------------------------------------------------

Expand Down Expand Up @@ -114,13 +112,11 @@ const UserProfileView = ({ id }: any) => {
}));

if (loadingProfile || loadingPublications) return (
<ProfileTags profile={profile}>
<LoadingScreen />
</ProfileTags>
<LoadingScreen />
);

return (
<ProfileTags profile={profile}>
<>
<Container maxWidth={settings.themeStretch ? false : 'lg'} sx={{ overflowX: 'hidden' }}>
<ProfileHeader profile={profile as any}>
<Tabs
Expand Down Expand Up @@ -157,7 +153,7 @@ const UserProfileView = ({ id }: any) => {
{currentTab === 'following' && profile && <ProfileFollowing />}
{currentTab === 'referrals' && sessionData?.profile?.id === id && <ProfileReferrals referrals={referrals} loading={loadingReferrals} />}
</Container>
</ProfileTags>
</>
);
};

Expand All @@ -170,24 +166,4 @@ const TabLabel = ({ label, count }: any) => (
</>
);

interface ProfileTagsProps {
profile: any
}

const ProfileTags: FC<PropsWithChildren<ProfileTagsProps>> = ({ profile, children }) => {
// OG META TAGS DATA
const title = `Watchit: Profile of "${profile?.metadata?.displayName}"`
const description = 'Discover this user’s profile on Watchit, a decentralized platform powered by Web3 & AI.'
const url = `${GLOBAL_CONSTANTS.BASE_URL}/profile/${profile?.id}`

return <OgMetaTags
title={title}
description={description}
url={url}
>
{children}
</OgMetaTags>
}


export default UserProfileView;

0 comments on commit bfc151b

Please sign in to comment.