Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO setup #285

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PageTitle, Paragraph } from '@components/typography';
import AboutCard from './AboutCard';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

interface Feedback {
avatar: string;
Expand Down Expand Up @@ -73,6 +75,12 @@ const DATA: Array<Feedback> = [

export const metadata: Metadata = {
title: 'About',
description:
'Learn more about me through the words of some of my close friends, managers and peers.',
openGraph: {
url: new URL(`${BASE_URL}/about`),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
6 changes: 6 additions & 0 deletions src/app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Mdx } from '@components/mdx';
import { allBlogs } from '@contentlayer/generated';
import { type Metadata } from 'next';
import ViewTracker from './ViewTracker';
import { BASE_URL } from '../../../utils/const';
import { OG_IMAGE } from '../../../utils/ogImage';

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = params;
Expand All @@ -11,6 +13,10 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
return {
title: blogPost?.title,
description: blogPost?.summary,
openGraph: {
url: new URL(`${BASE_URL}/blog/${slug}`),
images: [OG_IMAGE],
},
};
}

Expand Down
8 changes: 8 additions & 0 deletions src/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import { PageTitle, Paragraph, SectionTitle } from '@components/typography';
import ArticlePreview from '@components/ArticlePreview';
import { type Metadata } from 'next';
import { getAllBlogPosts } from '@lib/models/blog';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

export const revalidate = 0;

export const metadata: Metadata = {
title: 'Blog',
description:
'Weekly content about software development and management. All articles are based on my own experience and real cases.',
openGraph: {
url: new URL(`${BASE_URL}/blog`),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
7 changes: 7 additions & 0 deletions src/app/emoji/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import Emoji from './Emoji';
import { PageTitle, Paragraph } from '@components/typography';
import { getAllEmojis } from '@lib/models/emoji';
import { type Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

export const revalidate = 0;

export const metadata: Metadata = {
title: 'Emoji',
description: 'Here you can have fun and vote for your favorite emoji.',
openGraph: {
url: new URL(`${BASE_URL}/emoji`),
images: [OG_IMAGE],
},
};

async function Page() {
Expand Down
8 changes: 8 additions & 0 deletions src/app/gallery/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

export const metadata: Metadata = {
title: 'Gallery',
description:
'I like photography and here are a couple of my favorite pictures.',
openGraph: {
url: new URL(`${BASE_URL}/gallery`),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
5 changes: 5 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Analytics } from '@vercel/analytics/react';
import type { Metadata } from 'next';
import Container from '@components/Container';
import './globals.css';
import { BASE_URL } from '../utils/const';

const redHatText = Red_Hat_Text({
variable: '--font-red-hat-text',
Expand All @@ -25,6 +26,10 @@ export const metadata: Metadata = {
template: '%s | Kirill Kurko',
default: 'Kirill Kurko',
},
alternates: {
canonical: './',
},
metadataBase: new URL(`${BASE_URL}/`),
};

interface Props {
Expand Down
7 changes: 7 additions & 0 deletions src/app/newsletter/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

export const metadata: Metadata = {
title: 'Newsletter',
description: 'Follow my newsletter on software development and management.',
openGraph: {
url: new URL(`${BASE_URL}/newsletter`),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
Binary file added src/app/opengraph-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { PageTitle, Paragraph } from '@components/typography';
import type { Metadata } from 'next';
import { BASE_URL } from '../utils/const';
import { OG_IMAGE } from '../utils/ogImage';

export const metadata: Metadata = {
title: 'kkurko.dev',
description: 'Frontend Developer, creator, and penguin.',
description: 'Frontend Developer and Penguin 🐧',
openGraph: {
url: new URL(BASE_URL),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
8 changes: 8 additions & 0 deletions src/app/snippets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';

export const metadata: Metadata = {
title: 'Snippets',
description:
'Short code snippets that I found useful and want to keep at hand.',
openGraph: {
url: new URL(`${BASE_URL}/snippets`),
images: [OG_IMAGE],
},
};

function Page() {
Expand Down
1 change: 1 addition & 0 deletions src/utils/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BASE_URL = 'https://kkurko.dev';
7 changes: 7 additions & 0 deletions src/utils/ogImage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ogImage from '../app/opengraph-image.png';

export const OG_IMAGE = {
url: ogImage.src,
width: ogImage.width,
height: ogImage.height,
};
Loading