This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

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

BaseUrl string
URL prefix under which card routes are published (e.g. /social-cards/blog/post.png).
ContentType string
MIME type served for, and meta-tagged on, the generated card.
Height int
Card height in pixels passed to Render. Defaults to the 1200x630 OpenGraph standard.
Render Func<SocialCardRequest, IServiceProvider, CancellationToken, Task<byte[]>>
required
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).
Width int
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; }
}