Skip to content

Commit d9e8559

Browse files
committed
Added some SEO stuff
1 parent af24efa commit d9e8559

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

app/(main)/threads/[id]/page.tsx

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,104 @@ export async function generateMetadata({ params }: ThreadPageProps): Promise<Met
1717

1818
if (!article) {
1919
return {
20-
title: 'Thread Not Found',
20+
title: 'Thread Not Found | Refetch',
2121
description: 'The requested thread could not be found.',
22+
robots: 'noindex, nofollow',
2223
}
2324
}
2425

2526
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://refetch.io'
27+
const canonicalUrl = `${baseUrl}/threads/${article.id}`
2628

29+
// Enhanced metadata for better SEO
2730
return {
2831
title: `${article.title} | Refetch`,
29-
description: article.description || `Discussion about ${article.title}`,
32+
description: article.description || `Discussion about ${article.title}. Join the conversation on Refetch, the open-source alternative to YC-controlled HN.`,
33+
keywords: [
34+
'tech news',
35+
'discussion',
36+
'community',
37+
'open source',
38+
'hacker news alternative',
39+
'refetch',
40+
article.domain,
41+
...(article.description ? article.description.split(' ').slice(0, 10) : [])
42+
].filter(Boolean),
43+
authors: article.author ? [{ name: article.author }] : undefined,
44+
creator: 'Refetch',
45+
publisher: 'Refetch',
46+
formatDetection: {
47+
email: false,
48+
address: false,
49+
telephone: false,
50+
},
51+
metadataBase: new URL(baseUrl),
52+
alternates: {
53+
canonical: canonicalUrl,
54+
},
3055
openGraph: {
3156
title: article.title,
32-
description: article.description || `Discussion about ${article.title}`,
57+
description: article.description || `Discussion about ${article.title}. Join the conversation on Refetch.`,
3358
type: 'article',
34-
url: `${baseUrl}/threads/${article.id}`,
59+
url: canonicalUrl,
60+
siteName: 'Refetch',
61+
locale: 'en_US',
3562
images: [
3663
{
3764
url: `${baseUrl}/api/og/thread/${article.id}`,
3865
width: 2400,
3966
height: 1260,
4067
alt: article.title,
68+
type: 'image/png',
4169
},
4270
],
43-
siteName: 'Refetch',
71+
authors: article.author ? [article.author] : undefined,
72+
publishedTime: undefined, // NewsItem doesn't have $createdAt
73+
modifiedTime: undefined, // NewsItem doesn't have $updatedAt
74+
section: 'Technology',
75+
tags: [article.domain, 'tech news', 'discussion'],
4476
},
4577
twitter: {
4678
card: 'summary_large_image',
4779
title: article.title,
48-
description: article.description || `Discussion about ${article.title}`,
80+
description: article.description || `Discussion about ${article.title}. Join the conversation on Refetch.`,
4981
images: [`${baseUrl}/api/og/thread/${article.id}`],
82+
creator: '@refetch_io',
83+
site: '@refetch_io',
84+
},
85+
robots: {
86+
index: true,
87+
follow: true,
88+
googleBot: {
89+
index: true,
90+
follow: true,
91+
'max-video-preview': -1,
92+
'max-image-preview': 'large',
93+
'max-snippet': -1,
94+
},
95+
},
96+
verification: {
97+
google: process.env.GOOGLE_SITE_VERIFICATION,
98+
yandex: process.env.YANDEX_VERIFICATION,
99+
yahoo: process.env.YAHOO_VERIFICATION,
100+
},
101+
other: {
102+
'article:author': article.author,
103+
'article:section': 'Technology',
104+
'article:tag': [article.domain, 'tech news', 'discussion'],
105+
'og:image:width': '2400',
106+
'og:image:height': '1260',
107+
'og:image:type': 'image/png',
108+
'twitter:image:width': '2400',
109+
'twitter:image:height': '1260',
50110
},
51111
}
52112
} catch (error) {
53113
console.error('Error generating metadata:', error)
54114
return {
55115
title: 'Thread | Refetch',
56-
description: 'Tech news and discussions on Refetch.',
116+
description: 'Tech news and discussions on Refetch, the open-source alternative to YC-controlled HN.',
117+
robots: 'noindex, nofollow',
57118
}
58119
}
59120
}

0 commit comments

Comments
 (0)