Skip to content

Commit

Permalink
fix: use the cloudinary og image as a default
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhooks committed Feb 1, 2024
1 parent 97fb275 commit a232e03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/course-builder-web/src/app/[article]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function generateMetadata({ params, searchParams }: Props, parent:
return parent as Metadata
}

const customOgImage = article.socialImage
const customOgImage = article.socialImage || getOGImageUrlForTitle(article.title)

return {
title: article.title,
Expand Down
5 changes: 4 additions & 1 deletion apps/course-builder-web/src/trpc/api/routers/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getServerAuthSession } from '@/server/auth'
import { sanityMutation } from '@/server/sanity.server'
import { createTRPCRouter, protectedProcedure, publicProcedure } from '@/trpc/api/trpc'
import { toChicagoTitleCase } from '@/utils/chicagor-title'
import { getOGImageUrlForTitle } from '@/utils/get-og-image-for-title'
import slugify from '@sindresorhus/slugify'
import { customAlphabet } from 'nanoid'
import { v4 } from 'uuid'
Expand Down Expand Up @@ -73,7 +74,8 @@ export const articlesRouter = createTRPCRouter({
_type: 'article',
state: 'draft',
visibility: 'unlisted',
title: toChicagoTitleCase(input.title),
socialImage: getOGImageUrlForTitle(input.title),
title: input.title,
slug: {
current: slugify(`${input.title}~${nanoid()}`),
},
Expand All @@ -100,6 +102,7 @@ export const articlesRouter = createTRPCRouter({
set: {
'slug.current': `${slugify(input.title)}~${nanoid()}`,
title: toChicagoTitleCase(input.title),
socialImage: getOGImageUrlForTitle(input.title),
},
},
},
Expand Down

0 comments on commit a232e03

Please sign in to comment.