Skip to content

Commit

Permalink
Add blog posts opengraph images
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillkurko committed Mar 14, 2024
1 parent ea20ef4 commit 9b520ec
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 16 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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';
import { OG_IMAGE } from '../../utils/ogImages';

interface Feedback {
avatar: string;
Expand Down
4 changes: 2 additions & 2 deletions src/app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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';
import { getBlogPostOpengraphImage } from '../../../utils/ogImages';

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = params;
Expand All @@ -15,7 +15,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
description: blogPost?.summary,
openGraph: {
url: new URL(`${BASE_URL}/blog/${slug}`),
images: [OG_IMAGE],
images: [getBlogPostOpengraphImage(slug)],
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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';
import { OG_IMAGE } from '../../utils/ogImages';

export const metadata: Metadata = {
title: 'Blog',
Expand Down
2 changes: 1 addition & 1 deletion src/app/emoji/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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';
import { OG_IMAGE } from '../../utils/ogImages';

export const revalidate = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/app/gallery/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';
import { OG_IMAGE } from '../../utils/ogImages';

export const metadata: Metadata = {
title: 'Gallery',
Expand Down
2 changes: 1 addition & 1 deletion src/app/newsletter/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';
import { OG_IMAGE } from '../../utils/ogImages';

export const metadata: Metadata = {
title: 'Newsletter',
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PageTitle, Paragraph } from '@components/typography';
import type { Metadata } from 'next';
import { BASE_URL } from '../utils/const';
import { OG_IMAGE } from '../utils/ogImage';
import { OG_IMAGE } from '../utils/ogImages';

export const metadata: Metadata = {
title: 'kkurko.dev',
Expand Down
2 changes: 1 addition & 1 deletion src/app/snippets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImage';
import { OG_IMAGE } from '../../utils/ogImages';

export const metadata: Metadata = {
title: 'Snippets',
Expand Down
7 changes: 0 additions & 7 deletions src/utils/ogImage.ts

This file was deleted.

20 changes: 20 additions & 0 deletions src/utils/ogImages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ogImage from '../app/opengraph-image.png';

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

const DEFAULT_OG_IMAGE_SIZE = {
WIDTH: 1920,
HEIGHT: 1080,
};

export function getBlogPostOpengraphImage(slug: string) {
return {
url: `/images/${slug}/opengraph-image.png`,
width: DEFAULT_OG_IMAGE_SIZE.WIDTH,
height: DEFAULT_OG_IMAGE_SIZE.HEIGHT,
};
}

0 comments on commit 9b520ec

Please sign in to comment.