mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
fix: social image fixes
This commit is contained in:
@@ -4,16 +4,15 @@ import renderSocialImage from 'puppeteer-social-image-transitive-bs'
|
||||
import { getBlockIcon, getBlockTitle } from 'notion-utils'
|
||||
|
||||
import { mapNotionImageUrl } from '../../lib/map-image-url'
|
||||
import { getPageDescription } from '../../lib/get-page-description'
|
||||
import { getPage } from '../../lib/notion'
|
||||
import * as types from '../../lib/types'
|
||||
import {
|
||||
siteDescription,
|
||||
socialImageDescription,
|
||||
defaultPageCover,
|
||||
defaultPageIcon,
|
||||
siteDomain,
|
||||
siteName
|
||||
} from '../../lib/config'
|
||||
import { getPageDescription } from '../../lib/get-page-description'
|
||||
|
||||
export interface SocialImageConfig {
|
||||
title: string
|
||||
@@ -70,7 +69,6 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
.send({ error: `unable to load notion page "${pageId}"` })
|
||||
}
|
||||
|
||||
// TODO: centralize these default config values
|
||||
const image = await createSocialImage({
|
||||
imageUrl: mapNotionImageUrl(
|
||||
block.format?.page_cover ?? defaultPageCover,
|
||||
@@ -81,8 +79,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
getBlockIcon(block, recordMap) ?? defaultPageIcon,
|
||||
block
|
||||
),
|
||||
subtitle: getPageDescription(block, recordMap) ?? siteDescription,
|
||||
watermark: siteDomain
|
||||
subtitle: getPageDescription(block, recordMap) ?? socialImageDescription
|
||||
})
|
||||
|
||||
res.setHeader(
|
||||
|
||||
@@ -100,7 +100,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
|
||||
|
||||
const isBlogPost =
|
||||
block.type === 'page' && block.parent_table === 'collection'
|
||||
const socialImage = mapImageUrl(api.renderSocialImage(pageId))
|
||||
const socialImage = api.renderSocialImage(pageId)
|
||||
const socialDescription =
|
||||
getPageDescription(block, recordMap) ?? siteDescription
|
||||
let comments: React.ReactNode = null
|
||||
@@ -154,7 +154,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
|
||||
{canonicalPageUrl && (
|
||||
<>
|
||||
<link rel='canonical' href={canonicalPageUrl} />
|
||||
|
||||
<meta property='og:url' content={canonicalPageUrl} />
|
||||
<meta property='twitter:url' content={canonicalPageUrl} />
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -17,6 +17,7 @@ export const siteDomain = 'transitivebullsh.it'
|
||||
export const siteDescription =
|
||||
'Personal site of Travis Fischer aka Transitive Bullshit'
|
||||
export const siteFavicon = `https://${siteDomain}/favicon.png`
|
||||
export const socialImageDescription = '(Travis Fischer)'
|
||||
|
||||
// default notion values for site-wide consistency (may be overridden on a per-page basis)
|
||||
export const defaultPageIcon =
|
||||
|
||||
Reference in New Issue
Block a user