Skip to content

Commit

Permalink
feat: 사이트맵, robots.txt 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
junseokku committed Jun 6, 2024
1 parent 032c133 commit 63f9c74
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
5 changes: 1 addition & 4 deletions app/constants/SEOConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export const SEOConfig: Metadata = {
referrer: 'origin-when-cross-origin',
creator: myInfo.name,
publisher: myInfo.name,
authors: [
{ name: myInfo.nickname },
// TODO - { url: 'https://junseokku.dev' },
],
authors: [{ name: myInfo.nickname }, { url: myInfo.blog.url }],
twitter: {
title: myInfo.blog.name,
description: myInfo.description,
Expand Down
1 change: 1 addition & 0 deletions app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function generateMetadata({ params }: Params): Promise<Metadata> {
title,
description,
alternates: { canonical: url },
keywords: targetPost.tags,
openGraph: {
url,
title,
Expand Down
32 changes: 32 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { MetadataRoute } from 'next';
import { myInfo } from './constants/myInfo';
import { allPosts } from 'contentlayer/generated';

export default function sitemap(): MetadataRoute.Sitemap {
const sitemapPosts = generateSitemapPosts();

return [
{
url: `${myInfo.blog.url}`,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 1,
},
{
url: `${myInfo.blog.url}/posts`,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 0.8,
},
...sitemapPosts,
];
}

const generateSitemapPosts = (): MetadataRoute.Sitemap => {
return allPosts.map((post) => ({
url: `${myInfo.blog.url}/${post._raw.flattenedPath}`,
lastModified: new Date(post.updatedAt ?? post.createdAt),
changeFrequency: 'daily',
priority: 0.8,
}));
};
2 changes: 1 addition & 1 deletion contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Post = defineDocumentType(() => ({
author: { type: 'string', required: true },
tags: { type: 'list', of: { type: 'string' }, required: true },
categories: { type: 'list', of: { type: 'string' }, required: true },
summary: { type: 'string', required: false },
summary: { type: 'string', required: true },
},
computedFields: {
url: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: '[번역] 타입 안전성 있게 Next.js에서 라우팅 하기'
createdAt: 2024-05-25
author: Junseokku
author: junseokku
tags: [translate, app-router, typed-safety, routing, 타입, 안정성, 라우팅]
categories: []
summary: ''
summary: 'Next,js Link(href, as), useRouter(.push(url, as))을 사용하는 등 라우팅 상황에서 런타임 검증과 타입 안정성 있게 라우팅하는 방법을 소개한다.'
---

> 원글: [https://www.flightcontrol.dev/blog/fix-nextjs-routing-to-have-full-type-safety](https://www.flightcontrol.dev/blog/fix-nextjs-routing-to-have-full-type-safety)
Expand Down
9 changes: 9 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# *
User-agent: *
Allow: /

# Host
Host: https://junseokku.dev

# Sitemaps
Sitemap: https://junseokku.dev/sitemap.xml

0 comments on commit 63f9c74

Please sign in to comment.