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

Blog improvements #286

Merged
merged 4 commits into from
Mar 14, 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
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
4 changes: 1 addition & 3 deletions src/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +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';

export const revalidate = 0;
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
Binary file modified src/app/favicon.ico
Binary file not shown.
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
3 changes: 3 additions & 0 deletions src/lib/models/blog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import prisma from '@lib/prisma';
import { allBlogs } from '@contentlayer/generated';
import { unstable_noStore as noStore } from 'next/cache';

export function getAllBlogPosts() {
return allBlogs.sort((a, b) => {
Expand All @@ -11,6 +12,8 @@ export function getAllBlogPosts() {
}

export async function getBlogPostViews() {
noStore();

const views = await prisma.blog.findMany();

return Object.fromEntries(views.map((view) => [view.slug, view.views]));
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,
};
}
Loading