Skip to content

Publish plugin to generate images from your posts. Ideal for Twitter Cards.

License

Notifications You must be signed in to change notification settings

alexito4/ItemPosterPublishPlugin

Repository files navigation

ItemPosterPublishPlugin

Status Swift 5.3 Swift Package Manager Mac Publish Plugin Twitter: @alexito4

Create social images for your posts to have nice Twitter Cards. This is a plugin for Publish.

⚠️ Note that the poster generation must run on MainActor but Publish 0.9.0 doesn't support concurrency properly and it cause a deadlock. You will need a workaround (like this commit) and make your command line tool be async.

Installation

Add the package to your SPM dependencies.

.package(name: "ItemPosterPublishPlugin", url: "https://github.com/alexito4/ItemPosterPublishPlugin", from: "0.0.1"),

Usage

The plugin can then be used within any publishing pipeline like this:

import PublishReadingTime
...
try DeliciousRecipes().publish(using: [
    ...
    .addMarkdownFiles(),
    .installPlugin(
        .itemPosterPublishPlugin(
            viewForItem: { item in
                Poster(title: item.title)
            },
            size: CGSize(width: 1600, height: 840)
        )
    )
    ...
])

Note that it must be installed after the Items are created (in this case by addMarkdownFiles() ).

Author

Alejandro Martinez | http://alejandromp.com | @alexito4