Skip to content

Commit 85aef6c

Browse files
committed
Fix indexed error URLs
1 parent e883530 commit 85aef6c

4 files changed

Lines changed: 29 additions & 149 deletions

File tree

app/posts/[title]/opengraph-image.tsx

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

app/posts/[title]/page.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ export async function generateMetadata({
9393

9494
const articleUrl = absoluteUrl(`/posts/${article.slug}`);
9595
const articleImage = absoluteUrl(article.img);
96-
const generatedOgImage = absoluteUrl(
97-
`/posts/${article.slug}/opengraph-image`,
98-
);
9996
const authorUrl = article.author?.slug
10097
? absoluteUrl(`/team/${article.author.slug}`)
10198
: undefined;
@@ -125,12 +122,6 @@ export async function generateMetadata({
125122
url: articleImage,
126123
alt: article.imgAlt || article.title,
127124
},
128-
{
129-
url: generatedOgImage,
130-
width: 1200,
131-
height: 630,
132-
alt: `${article.title} on ${SITE_NAME}`,
133-
},
134125
],
135126
},
136127
twitter: {
@@ -158,10 +149,9 @@ export default async function ArticleDetails({
158149
const articleUrl = absoluteUrl(`/posts/${article.slug}`);
159150
const articleImages = Array.from(
160151
new Set(
161-
[
162-
article.img ? absoluteUrl(article.img) : null,
163-
absoluteUrl(`/posts/${article.slug}/opengraph-image`),
164-
].filter((value): value is string => Boolean(value)),
152+
[article.img ? absoluteUrl(article.img) : null].filter(
153+
(value): value is string => Boolean(value),
154+
),
165155
),
166156
);
167157
const latestArticles = (await getPublishedArticles())

netlify.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
[[plugins]]
66
package = "@netlify/plugin-nextjs"
77

8+
[[redirects]]
9+
from = "/&"
10+
to = "/"
11+
status = 301
12+
force = true
13+
14+
[[redirects]]
15+
from = "/posts/*/opengraph-image"
16+
to = "/og-image.png"
17+
status = 301
18+
force = true
19+
820
[[redirects]]
921
from = "https://www.lap.onl/*"
1022
to = "https://lap.onl/:splat"

next.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ const nextConfig = {
44
typescript: {
55
ignoreBuildErrors: false,
66
},
7+
async redirects() {
8+
return [
9+
{
10+
source: "/&",
11+
destination: "/",
12+
permanent: true,
13+
},
14+
{
15+
source: "/posts/:title/opengraph-image",
16+
destination: "/og-image.png",
17+
permanent: true,
18+
},
19+
];
20+
},
721
images: {
822
remotePatterns: [
923
{

0 commit comments

Comments
 (0)