Skip to content

Commit

Permalink
feat: remove puppeteer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 21, 2021
1 parent afaed50 commit d450d1f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 150 deletions.
129 changes: 0 additions & 129 deletions api/render-social-image/[pageId].ts

This file was deleted.

9 changes: 4 additions & 5 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ export const NotionPage: React.FC<types.PageProps> = ({
const showTableOfContents = !!isBlogPost
const minTableOfContentsItems = 3

const socialImage =
mapNotionImageUrl(
(block as PageBlock).format?.page_cover || config.defaultPageCover,
block
) || config.api.renderSocialImage(pageId)
const socialImage = mapNotionImageUrl(
(block as PageBlock).format?.page_cover || config.defaultPageCover,
block
)

const socialDescription =
getPageDescription(block, recordMap) ?? config.description
Expand Down
3 changes: 1 addition & 2 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ export const apiBaseUrl = `${host}/api`

export const api = {
createPreviewImage: `${apiBaseUrl}/create-preview-image`,
searchNotion: `${apiBaseUrl}/search-notion`,
renderSocialImage: (pageId) => `${apiBaseUrl}/render-social-image/${pageId}`
searchNotion: `${apiBaseUrl}/search-notion`
}

// ----------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
"notion-utils": "^4.4.0",
"p-map": "^4.0.0",
"p-memoize": "^4.0.0",
"puppeteer-core": "^5.5.0",
"puppeteer-social-image-transitive-bs": "^0.8.2",
"react": "^17.0.2",
"react-body-classname": "^1.3.1",
"react-dom": "^17.0.2",
Expand Down Expand Up @@ -74,7 +72,6 @@
"eslint-plugin-react": "^7.23.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"puppeteer": "^5.5.0",
"typescript": "^4.1.3"
}
}
11 changes: 0 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,6 @@ The actual work happens in the [create-preview-image](./api/create-preview-image

Open Graph images like this one will be generated for each page of your site automatically based each page's content.

By default, it takes into account:

- cover image (falling back to a default site-wide cover image)
- page icon (falling back to a default site-wide icon)
- page title
- page subtitle (optional; pulled from the "Description" property of collection pages)

This feature works by rendering some custom HTML to a [Puppeteer](https://pptr.dev) instance in this [serverless function](./api/render-social-image/[pageId].ts) that takes in the page ID as input.

Here's an example of a social image URL in production: [/api/render-social-image/71201624b204481f862630ea25ce62fe](https://transitivebullsh.it/api/render-social-image/71201624b204481f862630ea25ce62fe)

Note that you shouldn't have to do anything extra to enable this feature as long as you're deploying to Vercel.

### Automatic Table of Contents
Expand Down

0 comments on commit d450d1f

Please sign in to comment.