manifold/og-image
2022-05-25 17:14:19 -04:00
..
.github Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
api Threaded free response comments & general comments sections (#121) 2022-05-03 14:38:40 -06:00
public Dynamically generate Opengraph images for each market (#21) 2022-01-10 00:50:31 -05:00
web Revert "Give event in Dropdown an explicit type" 2022-05-25 17:14:19 -04:00
.gitignore Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
.vercelignore Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
.yarnrc Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
CONTRIBUTING.md Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
LICENSE Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
package.json Use the generated OpenGraph card in all markets (#23) 2022-01-10 02:05:24 -05:00
README.md Fix local dev setup 2022-01-07 12:16:51 -08:00
vercel.json Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00
yarn.lock Set up a custom OpenGraph image generator for social media previews (#20) 2022-01-07 12:07:38 -08:00

Quickstart

  1. To get started: yarn install
  2. To test locally: yarn start The local image preview is broken for some reason; but the service works. E.g. try http://localhost:3000/manifold.png
  3. To deploy: push to Github

For more info, see Contributing.md

  • note2: You may have to configure Vercel the first time:

    $ yarn start
    yarn run v1.22.10
    $ cd .. && vercel dev
    Vercel CLI 23.1.2 dev (beta) — https://vercel.com/feedback
    ? Set up and develop “~/Code/mantic”? [Y/n] y
    ? Which scope should contain your project? Mantic Markets
    ? Found project “mantic/mantic”. Link to it? [Y/n] n
    ? Link to different existing project? [Y/n] y
    ? Whats the name of your existing project? manifold-og-image
    
  • note2: (Not dev because that's reserved for Vercel)

  • note3: (Or cd .. && vercel --prod, I think)

(Everything below is from the original repo)

Open Graph Image as a Service

Serverless service that generates dynamic Open Graph images that you can embed in your <meta> tags.

For each keystroke, headless chromium is used to render an HTML page and take a screenshot of the result which gets cached.

See the image embedded in the tweet for a real use case.

What is an Open Graph Image?

Have you ever posted a hyperlink to Twitter, Facebook, or Slack and seen an image popup? How did your social network know how to "unfurl" the URL and get an image? The answer is in your <head>.

The Open Graph protocol says you can put a <meta> tag in the <head> of a webpage to define this image.

It looks like the following:

<head>
  <title>Title</title>
  <meta property="og:image" content="http://example.com/logo.jpg" />
</head>

Why use this service?

The short answer is that it would take a long time to painstakingly design an image for every single blog post and every single documentation page. And we don't want the exact same image for every blog post because that wouldn't make the article stand out when it was shared to Twitter.

That's where og-image.vercel.app comes in. We can simply pass the title of our blog post to our generator service and it will generate the image for us on the fly!

It looks like the following:

<head>
  <title>Hello World</title>
  <meta
    property="og:image"
    content="https://og-image.vercel.app/Hello%20World.png"
  />
</head>

Now try changing the text Hello%20World to the title of your choosing and watch the magic happen

Deploy your own

You'll want to fork this repository and deploy your own image generator.

  1. Click the fork button at the top right of GitHub
  2. Clone the repo to your local machine with git clone URL_OF_FORKED_REPO_HERE
  3. Change directory with cd og-image
  4. Make changes by swapping out images, changing colors, etc (see contributing for more info)
  5. Remove all configuration inside vercel.json besides rewrites
  6. Run locally with vercel dev and visit localhost:3000 (if nothing happens, run npm install -g vercel)
  7. Deploy to the cloud by running vercel and you'll get a unique URL
  8. Connect Vercel for GitHub to automatically deploy each time you git push 🚀

Authors