Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Add og image (#317)

Sean Boultf725cf1346ff
diff --git a/public/real-og.png b/public/real-og.png
new file mode 100644
index 00000000..f5c2e879
Binary files /dev/null and b/public/real-og.png differ
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 63080209..30dbb5d4 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -5,12 +5,31 @@ import '../styles/globals.css';
import { Inter } from 'next/font/google';
import { Navigation } from '~/components/ui/navigation';
import { Toaster } from '~/components/ui/toaster';
+import type { Metadata } from 'next';
const inter = Inter({ subsets: ['latin'] });
-export const metadata = {
- title: 'Type Hero',
- description: 'Level up your typescript skills with interactive exercises',
-};
+
+const OG_IMAGE = '/real-og.png';
+export async function generateMetadata(): Promise<Metadata> {
+ const title = 'Type Hero';
+ const description = 'Level up your typescript skills with interactive exercises';
+ return {
+ title,
+ description,
+ openGraph: {
+ images: [OG_IMAGE],
+ description,
+ title,
+ type: 'website',
+ },
+ twitter: {
+ images: [OG_IMAGE],
+ title,
+ description,
+ card: 'summary_large_image',
+ },
+ };
+}
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
diff --git a/src/middleware.ts b/src/middleware.ts
index 1547eeb5..6cd08d62 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -1,6 +1,11 @@
import { type NextRequest, NextResponse } from 'next/server';
export function middleware(req: NextRequest) {
+ // don't allow auth on preview domains so we can test shit
+ if (req.headers.get("host") !== "typehero.dev") {
+ return NextResponse.next();
+ }
+
if (process.env.NODE_ENV === 'production') {
const basicAuth = req.headers.get('authorization');
const url = req.nextUrl;