Skip to content

Commit 879df46

Browse files
Merge pull request #71 from ShipFriend0516/fix/sitemap
fix: metadata, sitemap, rss, jsonld 등에서 잘못된 url 참조문제 수정
2 parents 9ad92bb + 1bdd8b1 commit 879df46

11 files changed

Lines changed: 32 additions & 13 deletions

File tree

app/api/portfolio/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const shipfriend: PortfolioItem = {
5151
category: '개인 블로그',
5252
links: {
5353
githubUrl: 'https://github.com/shipfriend0516/techblog',
54-
deployUrl: 'https://shipfriend.vercel.app',
54+
deployUrl: 'https://www.shipfriend.dev',
5555
},
5656
};
5757
const preview: PortfolioItem = {

app/api/redirect/recent/route.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ export const dynamic = 'force-dynamic'; // 캐싱 방지
77
export async function GET() {
88
try {
99
await dbConnect();
10-
const pageUrl = process.env.NEXTAUTH_URL;
10+
const pageUrl =
11+
process.env.NEXT_PUBLIC_DEPLOYMENT_URL ||
12+
process.env.NEXTAUTH_URL ||
13+
'https://shipfriend.dev';
1114

1215
// 최신 글 1개 가져오기
1316
const latestPost = await Post.findOne({}).sort({ date: -1 }).select('slug');
@@ -23,6 +26,10 @@ export async function GET() {
2326
);
2427
} catch (error) {
2528
console.error('Error redirecting to latest post:', error);
26-
return NextResponse.redirect(new URL(`${process.env.NEXTAUTH_URL}/posts`));
29+
const pageUrl =
30+
process.env.NEXT_PUBLIC_DEPLOYMENT_URL ||
31+
process.env.NEXTAUTH_URL ||
32+
'https://shipfriend.dev';
33+
return NextResponse.redirect(new URL(`${pageUrl}/posts`));
2734
}
2835
}

app/entities/post/api/postAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Post } from '@/app/types/Post';
44
interface GetPostDetailResponse {
55
post: Post;
66
}
7-
const URL = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000';
7+
const URL = process.env.NEXT_PUBLIC_DEPLOYMENT_URL || process.env.NEXT_PUBLIC_URL || 'http://localhost:3000';
88

99
export const getPostDetail = async (
1010
slug: string

app/entities/post/detail/PostJSONLd.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Post } from '@/app/types/Post';
22

33
const PostJSONLd = ({ post }: { post: Post }) => {
4+
const baseUrl =
5+
process.env.NEXT_PUBLIC_DEPLOYMENT_URL ||
6+
process.env.NEXT_PUBLIC_URL ||
7+
'https://shipfriend.dev';
8+
49
return (
510
<script
611
type="application/ld+json"
@@ -28,7 +33,7 @@ const PostJSONLd = ({ post }: { post: Post }) => {
2833
name: 'ShipFriend TechBlog',
2934
logo: {
3035
'@type': 'ImageObject',
31-
url: `https://oraciondev.vercel.app/favicon.ico`,
36+
url: `${baseUrl}/favicon.ico`,
3237
},
3338
},
3439
}),

app/layout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export const metadata: Metadata = {
2727
openGraph: {
2828
title: 'ShipFriend TechBlog',
2929
description: '문제 해결 경험과 개발 지식을 공유하는 개발 블로그입니다.',
30-
url:
31-
process.env.NEXT_PUBLIC_DEPLOYMENT_URL || 'https://shipfriend.vercel.app',
30+
url: process.env.NEXT_PUBLIC_DEPLOYMENT_URL || 'https://www.shipfriend.dev',
3231
siteName: 'ShipFriend TechBlog',
3332
images: [
3433
{

app/lib/email/resend.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Resend } from 'resend';
22
import {
3-
getVerificationEmailHTML,
43
getNewPostEmailHTML,
54
getUnsubscribeEmailHTML,
5+
getVerificationEmailHTML,
66
} from './templates';
77

88
if (!process.env.RESEND_API_KEY) {
@@ -12,7 +12,10 @@ if (!process.env.RESEND_API_KEY) {
1212
const resend = new Resend(process.env.RESEND_API_KEY);
1313

1414
const FROM_EMAIL = process.env.EMAIL_FROM || '';
15-
const BASE_URL = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000';
15+
const BASE_URL =
16+
process.env.NEXT_PUBLIC_DEPLOYMENT_URL ||
17+
process.env.NEXT_PUBLIC_URL ||
18+
'https://shipfriend.dev';
1619

1720
export async function sendVerificationEmail(
1821
email: string,

app/lib/rss.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import { Feed } from 'feed';
44

55
export async function generateRssFeed(posts: any[]) {
6-
const site_url = process.env.NEXTAUTH_URL || 'http://localhost:3000';
6+
const site_url = process.env.NEXT_PUBLIC_DEPLOYMENT_URL || process.env.NEXTAUTH_URL || 'http://localhost:3000';
77

88
const feedOptions = {
99
title: 'ShipFriend TechBlog',

app/portfolio/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const projects: Project[] = [
2323
description: '개인 개발 블로그',
2424
image: '/images/logo/shipfriend-logo.webp',
2525
tags: ['Next.js', 'TypeScript', 'MongoDB'],
26-
demoUrl: 'https://shipfriend.vercel.app/',
26+
demoUrl: 'https://shipfriend.dev/',
2727
githubUrl: 'https://github.com/ShipFriend0516/TechBlog',
2828
slug: 'shipfriend',
2929
},

app/posts/[slug]/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ export const generateMetadata = async ({
4343
params: { slug: string };
4444
}): Promise<Metadata> => {
4545
const { post } = await getPostDetail(params.slug);
46+
const baseUrl =
47+
process.env.NEXT_PUBLIC_DEPLOYMENT_URL || 'https://shipfriend.dev';
48+
const postUrl = `${baseUrl}/posts/${post.slug}`;
49+
4650
return {
4751
title: post.title,
4852
description: post.subTitle || post.content.substring(0, 160),
4953
openGraph: {
5054
title: post.title,
5155
description: post.subTitle || post.content.substring(0, 160),
56+
url: postUrl,
5257
images: [post.thumbnailImage || defaultThumbnail],
5358
type: 'article',
5459
publishedTime: new Date(post.createdAt).toISOString(),

app/robots.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { MetadataRoute } from 'next';
33

44
export default function robots(): MetadataRoute.Robots {
5-
const baseURL = process.env.NEXTAUTH_URL || 'http://localhost:3000';
5+
const baseURL = process.env.NEXT_PUBLIC_DEPLOYMENT_URL || process.env.NEXTAUTH_URL || 'http://localhost:3000';
66
return {
77
rules: {
88
userAgent: '*',

0 commit comments

Comments
 (0)