Skip to content

Commit

Permalink
feat: add general og image and update metadata pages (#134)
Browse files Browse the repository at this point in the history
* feat: update general meta data

* feat: update room meta data

* fix: fix package-lock.json typescript version

* fix: og and twitter meta title and desc should be same

* Revert "fix: og and twitter meta title and desc should be same"

This reverts commit 3807ffc.

* revert: revert metadata not-found

* refactor: remove unused metadata

* fix: update title and description copywriting

* feat: use metadatabase

* feat: add metadata for room detail page

* fix: remove origin url

* feat: title for create event page

* feat: add  inlive room section after title

* refactor: default app origin is empty string

* fix: omit url from default open graph in layout.tsx

* fix: remove og url
  • Loading branch information
faiq-naufal authored Jan 31, 2024
1 parent 7ba4d84 commit e2e9c0b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 21 deletions.
6 changes: 0 additions & 6 deletions app/(pages)/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import type { Metadata } from 'next';
import Home from '@/_features/home/home';
import { headers } from 'next/headers';
import AppContainer from '@/_shared/components/containers/app-container';
import type { AuthType } from '@/_shared/types/auth';

export const metadata: Metadata = {
title: 'inLive Room',
description: 'Conference room for real-time video and audio calls',
};

export default async function Page() {
const headersList = headers();
const userAuthHeader = headersList.get('user-auth');
Expand Down
10 changes: 4 additions & 6 deletions app/(pages)/event/[eventID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { InternalApiFetcher } from '@/_shared/utils/fetcher';
import type { AuthType } from '@/_shared/types/auth';
import type { EventType } from '@/_shared/types/event';

const APP_ORIGIN = process.env.NEXT_PUBLIC_APP_ORIGIN;

type PageProps = {
params: {
eventID: string;
Expand Down Expand Up @@ -95,18 +93,18 @@ export const generateMetadata = async ({
)}`;

return {
title: `Webinar — ${eventData.name}`,
title: `Webinar — ${eventData.name} — inLive Room`,
description: descriptionSummary,
openGraph: {
title: `Webinar — ${eventData.name}`,
title: `Webinar — ${eventData.name} — inLive Room`,
description: descriptionSummary,
url: `${APP_ORIGIN}/event/${eventData.slug}`,
url: `/event/${eventData.slug}`,
images: [imageSrc],
type: 'website',
},
twitter: {
card: 'summary_large_image',
title: `Webinar — ${eventData.name}`,
title: `Webinar — ${eventData.name} — inLive Room`,
description: descriptionSummary,
images: [imageSrc],
},
Expand Down
5 changes: 5 additions & 0 deletions app/(pages)/event/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { Metadata } from 'next';
import { headers } from 'next/headers';
import AppContainer from '@/_shared/components/containers/app-container';
import EventForm from '@/_features/event/components/event-form';
import { AuthType } from '@/_shared/types/auth';
import HTTPError from '@/_shared/components/errors/http-error';

export const metadata: Metadata = {
title: 'Create Your Event — inLive Room',
};

export default async function Page() {
const headersList = headers();
const userAuthHeader = headersList.get('user-auth');
Expand Down
2 changes: 1 addition & 1 deletion app/(pages)/room/[roomID]/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { headers } from 'next/headers';
import type { AuthType } from '@/_shared/types/auth';

export const metadata: Metadata = {
title: 'Room Not Found',
title: 'Room Not Found — inLive Room',
description: 'There is nothing to see on this page',
};

Expand Down
37 changes: 31 additions & 6 deletions app/(pages)/room/[roomID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,40 @@ import type { ClientType } from '@/_shared/types/client';
import { serverSDK } from '@/(server)/_shared/utils/sdk';

type PageProps = {
params: {
roomID: string;
};
searchParams: { debug: string | undefined };
};

export const generateMetadata = ({ params }: PageProps): Metadata => {
export const generateMetadata = (): Metadata | null => {
const headersList = headers();
const roomDataHeader = headersList.get('room-data');
const roomData: RoomType.RoomData | null =
typeof roomDataHeader === 'string'
? JSON.parse(roomDataHeader)
: roomDataHeader;

if (!roomData || !roomData.id) return null;

const type = roomData.meta?.type === 'event' ? 'Webinar' : 'Meeting';
const description =
'Experience real-time messaging, video, and audio for seamless collaboration, all within inLive Room.';
const ogImage = '/images/general-og.png';

return {
title: `Room - ${params.roomID}`,
title: `${type} Room: ${roomData.id} — inLive Room`,
description: description,
openGraph: {
title: `Join the ${type.toLocaleLowerCase()} room — inLive Room`,
description: description,
url: `/room/${roomData.id}`,
images: [ogImage],
type: 'website',
},
twitter: {
card: 'summary_large_image',
title: `Join the ${type.toLocaleLowerCase()} room — inLive Room`,
description: description,
images: [ogImage],
},
};
};

Expand Down Expand Up @@ -97,7 +122,7 @@ export default async function Page({ searchParams }: PageProps) {
midBitrate: hubRoomResponse?.data?.bitrates.videoMid || 0,
lowBitrate: hubRoomResponse?.data?.bitrates.videoLow || 0,
};
const roomType = roomData.meta ? roomData.meta.type : 'meeting' || 'meeting';
const roomType = roomData.meta ? roomData.meta.type : 'meeting';

return (
<AppContainer user={userAuth}>
Expand Down
24 changes: 24 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import type { Metadata } from 'next';
import '@/_shared/styles/tailwind.css';
import { Inter } from 'next/font/google';
import { MixpanelContainer } from '@/_shared/components/analytics/mixpanel';
import { Suspense } from 'react';

const inter = Inter({ subsets: ['latin'] });

const APP_ORIGIN = process.env.NEXT_PUBLIC_APP_ORIGIN || '';
const title = 'Virtual room for your real-time collaboration — inLive Room';
const description = `Host or join in seconds. It's that simple! Experience real-time messaging, video, and audio for seamless collaboration, all within open-source virtual rooms.`;
const ogImage = '/images/general-og.png';

export const metadata: Metadata = {
metadataBase: new URL(APP_ORIGIN),
title: title,
description: description,
openGraph: {
title: title,
description: description,
images: [ogImage],
type: 'website',
},
twitter: {
card: 'summary_large_image',
title: title,
description: description,
images: [ogImage],
},
};

export default function RootLayout({
children,
}: {
Expand Down
2 changes: 1 addition & 1 deletion app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { headers } from 'next/headers';
import type { AuthType } from '@/_shared/types/auth';

export const metadata: Metadata = {
title: 'Page Not Found',
title: 'Page Not Found — inLive Room',
description: 'There is nothing to see on this page',
};

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

Binary file added public/images/general-og.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2e9c0b

Please sign in to comment.