惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
B
Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
D
DataBreaches.Net
B
Blog RSS Feed
小众软件
小众软件
人人都是产品经理
人人都是产品经理
I
InfoQ
P
Proofpoint News Feed
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

Buttondown's blog

Email could have been X.400 times better The physicists who convinced Fermilab to send Brazil's emails Better in-app previews Analytics 3.0 Subscriber ID variables Comments! Send latest premium action Automation filtering Free API subscribers Surveys in automations Reply to replies Labels for RSS feeds How Jeremy Singer-Vine curates curious datasets for readers 2023 (and what's next) Email vs web content Sort by engagement Better gift subscriptions How Andy Dehnart built a career reviewing television New email template Email-based automations Opt-in reply tracking Automatic alt text More social network integrations Sort by metadata Overlarge image warnings Automation tag actions Pause emails mid-flight Search tags and automations Gift via automations Subscriber-driving emails
How we built made-for-you og:images
Ben Borgers · 2023-06-08 · via Buttondown's blog

Buttondown has the ability to add custom share images ("og:images") to your emails, which show up on social media sites when you share the link to your archived email.

We recently added a couple pre-filled templates that you can choose, as an alternative to designing your own image and uploading it:

The new templated share images available in Buttondown's settings. They're prefilled with your newsletter's name and email's subject.

We built this using Vercel's new @vercel/og package, built on Satori.

It generates the images directly, instead of the previously ubiquitous method of creating a screenshot using Puppeteer. That method was effective, but it takes a lot of infrastructure to run an entire Chrome browser just to take screenshots. Vercel's solution is lightweight and works beautifully with Next.js and Vercel's deployment platform (as expected, given that they made both).

The problem with a constrained environment like images is that a lot of possible edge cases can arise — most of them involving text that's longer than expected or not in the format you expected.

To mitigate this, I built a big page of test case so I could visually confirm that nothing's falling apart. I had a bit of fun with the test cases as well:

A page with 16 test og:images, each testing different edge cases such as "long author name."

I also built a randomized tester, which takes the most common English words and generates a nonsensical newsletter name and subject line. By clicking "randomize" over and over, I could get some additional confidence that the designs were resilient.

A button labelled "Randomize!" next to two share images, which contain randomly generated text.

(Of course, I'm sure there are edge cases that I didn't catch. If you find a combination of text that looks off, please let me know — support@buttondown.com!)

Now, the templates are piped into Buttondown's share image picker (which comes up when you click "Web archive" in the toolbar at the bottom). We use query string parameters to pass the newsletter's name and subject to render these dynamically.

The new templated share images available in Buttondown's settings. They're prefilled with your newsletter's name and email's subject.

Since Buttondown simply stores the URL of the share image, this required minimal changes to Buttondown's app. The custom-generated images are now available as an option, if you choose to use them.