SocialCardOptions
Pennington.SocialCards
Host configuration for social-card (OpenGraph / Twitter image) generation. Pennington owns the discovery, routing, and meta-tag wiring; the host owns the drawing via Render and brings its own image library (ImageSharp, SkiaSharp, Playwright, ...). Set this on SocialCards (templates forward it from their own options) to enable the feature; leaving it null disables it.
Properties
BaseUrlstring- URL prefix under which card routes are published (e.g.
/social-cards/blog/post.png). ContentTypestring- MIME type served for, and meta-tagged on, the generated card.
Heightint- Card height in pixels passed to
Render. Defaults to the 1200x630 OpenGraph standard. RenderFunc<SocialCardRequest, IServiceProvider, CancellationToken, Task<byte[]>>- requiredHost renderer invoked once per page to produce the card image bytes. Receives the request's
IServiceProviderso a renderer can resolve registered services (font caches, theming options, ...). Returnnullto skip a page (its card route then serves 404 and is omitted from the build). Widthint- Card width in pixels passed to
Render. Defaults to the 1200x630 OpenGraph standard.
Pennington.SocialCards.SocialCardOptions
namespace Pennington.SocialCards;
/// Host configuration for social-card (OpenGraph / Twitter image) generation. Pennington owns the discovery, routing, and meta-tag wiring; the host owns the drawing via Render and brings its own image library (ImageSharp, SkiaSharp, Playwright, ...). Set this on SocialCards (templates forward it from their own options) to enable the feature; leaving it null disables it.
public record SocialCardOptions
{
/// URL prefix under which card routes are published (e.g. /social-cards/blog/post.png).
public string BaseUrl { get; set; }
/// MIME type served for, and meta-tagged on, the generated card.
public string ContentType { get; set; }
/// Card height in pixels passed to Render. Defaults to the 1200x630 OpenGraph standard.
public int Height { get; set; }
/// Host renderer invoked once per page to produce the card image bytes. Receives the request's IServiceProvider so a renderer can resolve registered services (font caches, theming options, ...). Return null to skip a page (its card route then serves 404 and is omitted from the build).
public Func<SocialCardRequest, IServiceProvider, CancellationToken, Task<byte[]>> Render { get; set; }
/// Card width in pixels passed to Render. Defaults to the 1200x630 OpenGraph standard.
public int Width { get; set; }
}