Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default og metadata #4368

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions apps/og/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import type { Metadata } from 'next';
import type { ReactNode } from 'react';

import { APP_NAME, DESCRIPTION } from '@hey/data/constants';
import defaultMetadata from 'src/defaultMetadata';

export const metadata: Metadata = {
description: DESCRIPTION,
title: APP_NAME
};
export const metadata: Metadata = defaultMetadata;

export default function RootLayout({ children }: { children: ReactNode }) {
return (
Expand Down
9 changes: 3 additions & 6 deletions apps/og/src/app/posts/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import getProfile from '@hey/lib/getProfile';
import logger from '@hey/lib/logger';
import { isMirrorPublication } from '@hey/lib/publicationHelpers';
import { headers } from 'next/headers';
import defaultMetadata from 'src/defaultMetadata';

type Props = {
params: { id: string };
Expand All @@ -26,9 +27,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
});

if (!data.publication) {
return {
title: 'Publication not found'
};
return defaultMetadata;
}

const publication = data.publication as AnyPublication;
Expand All @@ -50,9 +49,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
type: 'article'
},
title: title,
twitter: {
card: 'summary'
}
twitter: { card: 'summary' }
};
}

Expand Down
9 changes: 3 additions & 6 deletions apps/og/src/app/u/[handle]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import getAvatar from '@hey/lib/getAvatar';
import getProfile from '@hey/lib/getProfile';
import logger from '@hey/lib/logger';
import { headers } from 'next/headers';
import defaultMetadata from 'src/defaultMetadata';

type Props = {
params: { handle: string };
Expand All @@ -25,9 +26,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
});

if (!data.profile) {
return {
title: 'Profile not found'
};
return defaultMetadata;
}

const profile = data.profile as Profile;
Expand All @@ -45,9 +44,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
type: 'profile'
},
title: title,
twitter: {
card: 'summary'
}
twitter: { card: 'summary' }
};
}

Expand Down
17 changes: 17 additions & 0 deletions apps/og/src/defaultMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Metadata } from 'next';

import { APP_NAME, DEFAULT_OG, DESCRIPTION } from '@hey/data/constants';

const defaultMetadata: Metadata = {
description: DESCRIPTION,
metadataBase: new URL(`https://hey.xyz`),
openGraph: {
images: [DEFAULT_OG],
siteName: 'Hey',
type: 'website'
},
title: APP_NAME,
twitter: { card: 'summary_large_image' }
};

export default defaultMetadata;
Loading