Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit 285f520

Browse files
committed
chore: archive unused OG image generation route and remove related code
Move the unused OG image generation route to an archive directory and comment out related code across the application. This change is made to clean up the codebase by removing unused functionality that is not currently needed. The archived code can be referenced in the future if required, while the commented-out sections prevent unnecessary processing and potential errors related to OG image generation.
1 parent fc8f003 commit 285f520

File tree

7 files changed

+216
-215
lines changed

7 files changed

+216
-215
lines changed

.archive/og/route.tsx

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// import { NextRequest } from 'next/server';
2+
3+
// // Remove edge runtime declaration that causes build errors
4+
// // export const runtime = 'edge';
5+
// export const fetchCache = 'force-no-store';
6+
// export const dynamic = 'force-dynamic';
7+
8+
// // Only declare the promise at top level, don't initialize it
9+
// let imageResponsePromise: Promise<any> | null = null;
10+
11+
// // This is a workaround for OpenNext + Cloudflare deployment
12+
// export async function GET(req: NextRequest) {
13+
// try {
14+
// const { searchParams } = new URL(req.url);
15+
16+
// // Get params from the request
17+
// const category = searchParams.get('category') || 'Blog';
18+
// const date =
19+
// searchParams.get('date') || new Date().toISOString().split('T')[0];
20+
21+
// // Convert date to more readable format
22+
// const formattedDate = new Date(date).toLocaleDateString('en-US', {
23+
// year: 'numeric',
24+
// month: 'long',
25+
// day: 'numeric',
26+
// });
27+
28+
// // Define category colors
29+
// const categoryColors: Record<string, string> = {
30+
// news: '#7C4DFF',
31+
// tutorials: '#00BFA5',
32+
// community: '#FF9100',
33+
// projects: '#2979FF',
34+
// guides: '#00C853',
35+
// };
36+
37+
// // Get color based on category or use default
38+
// const accentColor = categoryColors[category.toLowerCase()] || '#90A4AE';
39+
40+
// // Lazy-load ImageResponse to improve startup time
41+
// if (!imageResponsePromise) {
42+
// imageResponsePromise = import('next/og').then((mod) => mod.ImageResponse);
43+
// }
44+
45+
// const { ImageResponse } = await imageResponsePromise;
46+
47+
// return new ImageResponse(
48+
// (
49+
// <div
50+
// style={{
51+
// width: '100%',
52+
// height: '100%',
53+
// display: 'flex',
54+
// flexDirection: 'column',
55+
// alignItems: 'center',
56+
// justifyContent: 'center',
57+
// backgroundColor: '#0A0E15',
58+
// position: 'relative',
59+
// overflow: 'hidden',
60+
// }}
61+
// >
62+
// {/* Background accent */}
63+
// <div
64+
// style={{
65+
// position: 'absolute',
66+
// top: 0,
67+
// left: 0,
68+
// right: 0,
69+
// height: '627px',
70+
// background: `linear-gradient(to bottom, ${accentColor}50, transparent)`,
71+
// }}
72+
// />
73+
74+
// <div
75+
// style={{
76+
// display: 'flex',
77+
// flexDirection: 'column',
78+
// alignItems: 'flex-start',
79+
// textAlign: 'left',
80+
// padding: '0 80px',
81+
// width: '100%',
82+
// position: 'relative',
83+
// }}
84+
// >
85+
// {/* Logo/Site Name */}
86+
// <div
87+
// style={{
88+
// fontSize: 32,
89+
// fontWeight: 'bold',
90+
// color: 'white',
91+
// marginBottom: 30,
92+
// textShadow: '0 2px 4px rgba(0, 0, 0, 0.5)',
93+
// }}
94+
// >
95+
// All Things Linux
96+
// </div>
97+
98+
// {/* Category */}
99+
// <div
100+
// style={{
101+
// backgroundColor: accentColor,
102+
// color: '#0A0E15',
103+
// padding: '10px 20px',
104+
// borderRadius: 50,
105+
// fontSize: 28,
106+
// fontWeight: 'bold',
107+
// marginTop: 20,
108+
// marginBottom: 40,
109+
// boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)',
110+
// }}
111+
// >
112+
// {category}
113+
// </div>
114+
115+
// {/* Date */}
116+
// <div
117+
// style={{
118+
// fontSize: 56,
119+
// fontWeight: 'bold',
120+
// color: 'white',
121+
// marginBottom: 40,
122+
// textShadow: '0 2px 4px rgba(0, 0, 0, 0.5)',
123+
// }}
124+
// >
125+
// {formattedDate}
126+
// </div>
127+
128+
// {/* Domain */}
129+
// <div
130+
// style={{
131+
// fontSize: 24,
132+
// color: '#BDC3C7',
133+
// marginTop: 40,
134+
// }}
135+
// >
136+
// allthingslinux.org
137+
// </div>
138+
// </div>
139+
// </div>
140+
// ),
141+
// {
142+
// width: 1200,
143+
// height: 627,
144+
// headers: {
145+
// 'Cache-Control': 'no-store, max-age=0',
146+
// },
147+
// }
148+
// );
149+
// } catch (e) {
150+
// console.error(e);
151+
// // Create the Response inside the function body, not at top level
152+
// return new Response(`Failed to generate image`, {
153+
// status: 500,
154+
// });
155+
// }
156+
// }

app/api/og/route.tsx

Lines changed: 0 additions & 156 deletions
This file was deleted.

app/blog/[category]/[slug]/page.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BackToAllPostsButton } from '@/components/blog/back-to-posts-button';
55
import ClientScrollToTop from '@/components/blog/client-scroll-to-top';
66
import { ArticleSchema } from '@/components/structured-data';
77
import { getDynamicMetadata } from '@/app/metadata';
8-
import { getApiUrl, getBaseUrl } from '@/lib/utils';
8+
import { getBaseUrl } from '@/lib/utils';
99
import type { Metadata } from 'next';
1010

1111
interface PostPageProps {
@@ -31,18 +31,18 @@ export async function generateMetadata({
3131
}
3232

3333
// Convert category slug to proper name for display
34-
const categoryName =
35-
post.category ||
36-
category
37-
.split('-')
38-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
39-
.join(' ');
34+
// const categoryName =
35+
// post.category ||
36+
// category
37+
// .split('-')
38+
// .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
39+
// .join(' ');
4040

4141
// Build dynamic OG image URL with query parameters
42-
const ogImageUrl = new URL(getApiUrl('/api/og'));
43-
ogImageUrl.searchParams.append('title', post.title);
44-
ogImageUrl.searchParams.append('category', categoryName);
45-
ogImageUrl.searchParams.append('date', post.date);
42+
// const ogImageUrl = new URL(getApiUrl('/api/og'));
43+
// ogImageUrl.searchParams.append('title', post.title);
44+
// ogImageUrl.searchParams.append('category', categoryName);
45+
// ogImageUrl.searchParams.append('date', post.date);
4646

4747
return {
4848
...getDynamicMetadata({
@@ -54,14 +54,14 @@ export async function generateMetadata({
5454
description: post.description || `Read our post about ${post.title}`,
5555
type: 'article',
5656
url: `${getBaseUrl()}/blog/${category}/${slug}`,
57-
images: [
58-
{
59-
url: ogImageUrl.toString(),
60-
width: 1200,
61-
height: 630,
62-
alt: post.title,
63-
},
64-
],
57+
// images: [
58+
// {
59+
// url: ogImageUrl.toString(),
60+
// width: 1200,
61+
// height: 630,
62+
// alt: post.title,
63+
// },
64+
// ],
6565
publishedTime: post.date,
6666
modifiedTime: post.date,
6767
authors: [post.author || 'All Things Linux'],
@@ -70,7 +70,7 @@ export async function generateMetadata({
7070
card: 'summary_large_image',
7171
title: post.title,
7272
description: post.description || `Read our post about ${post.title}`,
73-
images: [ogImageUrl.toString()],
73+
// images: [ogImageUrl.toString()],
7474
},
7575
};
7676
}

0 commit comments

Comments
 (0)