From 1321f676cdccd271e7ce7ba34702f76a3a31f96b Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 17 Jan 2021 21:51:46 -0500 Subject: [PATCH] fix: social image fixes --- api/render-social-image/[pageId].ts | 9 +++------ components/NotionPage.tsx | 4 ++-- lib/config.ts | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/render-social-image/[pageId].ts b/api/render-social-image/[pageId].ts index 08a2614..0ffc2a5 100644 --- a/api/render-social-image/[pageId].ts +++ b/api/render-social-image/[pageId].ts @@ -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( diff --git a/components/NotionPage.tsx b/components/NotionPage.tsx index 36d912d..b381dd7 100644 --- a/components/NotionPage.tsx +++ b/components/NotionPage.tsx @@ -100,7 +100,7 @@ export const NotionPage: React.FC = ({ 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 = ({ {canonicalPageUrl && ( <> - + )} diff --git a/lib/config.ts b/lib/config.ts index 737ea4d..63f1b7a 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -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 =