{"_id":"@plugdash/socialcard","_rev":"5-9df7dfdf08ec82553b952c8ac074cc14","name":"@plugdash/socialcard","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@plugdash/socialcard","version":"0.1.0","keywords":["emdash","emdash-plugin","socialcard","og-image","open-graph","social-sharing"],"license":"MIT","_id":"@plugdash/socialcard@0.1.0","maintainers":[{"name":"abhinav061","email":"abhinav061@gmail.com"}],"homepage":"https://github.com/plugdash/plugdash#readme","bugs":{"url":"https://github.com/plugdash/plugdash/issues"},"dist":{"shasum":"4bd2fc2d5461a812425ae2e5fafbde11e661021b","tarball":"https://registry.npmjs.org/@plugdash/socialcard/-/socialcard-0.1.0.tgz","fileCount":2,"integrity":"sha512-+sA46azJezDR+GhmeLaukXSLIRuMCRarUGaUij6Hw8L2mIZIBpjGzJcxiLaInXo+kJyTtR1Q5ur4rnQOc6HgIg==","signatures":[{"sig":"MEQCIBwduDBn+zWAK5a0k0LujLgl1ILkFMbPefjGUInnIWzHAiARsHrPo586T1+XDy6nbFCb6vnToJvI7aCiz4hmePI+ew==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6057},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./card":{"types":"./dist/card.d.mts","import":"./dist/card.mjs"},"./sandbox":{"import":"./dist/sandbox-entry.mjs"}},"gitHead":"b25b6667c81891ddea3b04b2ef9a675e4697ddf2","scripts":{"lint":"oxlint .","test":"vitest run","build":"tsdown src/index.ts --dts.eager && tsdown src/sandbox-entry.ts --dts.eager --no-clean && tsdown src/card.ts --dts.eager --no-clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"abhinav061","email":"abhinav061@gmail.com"},"deprecated":"broken publish, use 0.1.1","repository":{"url":"git+https://github.com/plugdash/plugdash.git","type":"git","directory":"packages/socialcard"},"_npmVersion":"12.1.0","description":"OG social card generation for EmDash - builds a share image on publish and writes it to metadata.ogImage","directories":{},"_nodeVersion":"24.21.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.0.0","@plugdash/types":"workspace:*","@plugdash/testing":"workspace:*"},"peerDependencies":{"emdash":">=0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/socialcard_0.1.0_1790399881608_0.6767206221523663","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@plugdash/socialcard","version":"0.1.1","keywords":["emdash","emdash-plugin","socialcard","og-image","open-graph","social-sharing"],"license":"MIT","_id":"@plugdash/socialcard@0.1.1","maintainers":[{"name":"abhinav061","email":"abhinav061@gmail.com"}],"homepage":"https://github.com/plugdash/plugdash#readme","bugs":{"url":"https://github.com/plugdash/plugdash/issues"},"dist":{"shasum":"10d3d07ba1ac4acaf92e8c4ea1468c23e38d3f4a","tarball":"https://registry.npmjs.org/@plugdash/socialcard/-/socialcard-0.1.1.tgz","fileCount":15,"integrity":"sha512-x46XQbu5F5xLItMT1xpkaOdCzJrjAuFI5BljajzL0V78DBfeh5Ei84SEzeuhgeZHH/hdvvWLg2ghYSCKRfUSmA==","signatures":[{"sig":"MEQCIHQuz/NbDkZH2rXAJpcc7i5lXkWGHQS1FcRHJYx9BobWAiA4/bQPZ3DDcNCBl6kvkI6wa0Vgw0iuo2ZOxTR/X+94QA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCL4YtZoxBpWgIxKYzOaqDbopUwrMh8jAS8eWiaC1cPlwIhAIFCOEdTPTEhH7SL0Lw0zod9U/xng76DxxyLEwVa840p","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@plugdash%2fsocialcard@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":88137},"main":"./dist/index.mjs","type":"module","_from":"file:plugdash-socialcard-0.1.1.tgz","types":"./dist/index.d.mts","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./card":{"types":"./dist/card.d.mts","import":"./dist/card.mjs"},"./sandbox":{"import":"./dist/sandbox-entry.mjs"}},"scripts":{"lint":"oxlint .","test":"vitest run","build":"tsdown src/index.ts --dts.eager && tsdown src/sandbox-entry.ts --dts.eager --no-clean && tsdown src/card.ts --dts.eager --no-clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:837246c0-c991-4727-ae60-4cdf482fcc3f"}},"_resolved":"/tmp/e27d4b0c2540dce9efb37922ddcb8148/plugdash-socialcard-0.1.1.tgz","_integrity":"sha512-x46XQbu5F5xLItMT1xpkaOdCzJrjAuFI5BljajzL0V78DBfeh5Ei84SEzeuhgeZHH/hdvvWLg2ghYSCKRfUSmA==","repository":{"url":"git+https://github.com/plugdash/plugdash.git","type":"git","directory":"packages/socialcard"},"_npmVersion":"11.5.1","description":"OG social card generation for EmDash - builds a share image on publish and writes it to metadata.ogImage","directories":{},"_nodeVersion":"22.23.2","_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.0.0","@plugdash/types":"0.0.0","@plugdash/testing":"0.0.0"},"peerDependencies":{"emdash":">=0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/socialcard_0.1.1_1790404194545_0.5721627001677416","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@plugdash/socialcard","version":"0.1.2","keywords":["emdash","emdash-plugin","socialcard","og-image","open-graph","social-sharing"],"license":"MIT","_id":"@plugdash/socialcard@0.1.2","maintainers":[{"name":"abhinav061","email":"abhinav061@gmail.com"}],"homepage":"https://github.com/plugdash/plugdash#readme","bugs":{"url":"https://github.com/plugdash/plugdash/issues"},"dist":{"shasum":"52502bbfee30f5d36ea7e56e0f8eb14e7f0ac4af","tarball":"https://registry.npmjs.org/@plugdash/socialcard/-/socialcard-0.1.2.tgz","fileCount":15,"integrity":"sha512-ye57MVtTMf/pIuV88hAkPR/0VrUopYGvZIYHz/o9dfCde5nk3jQY8c9MPk09kpm7H8iEdqatt6qv1gmukBy3ew==","signatures":[{"sig":"MEQCIHssEi3pQ0v85I+UnvAGqLJHpB3vftBtl6L3f4J7HOgiAiAWdHsNOtxWQR4izqKqQZ3t5a6IzvCa5o8WPJQtAdWi4w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIGqnNewf+ZBDnx7p7c0z9rg9kEko7Q4qOzzA2xtHV0usAiBDpFgqEt52rncSz/4KxsFFnN5/z0Ao90ySdXHTFE9PhA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@plugdash%2fsocialcard@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":88284},"main":"./dist/index.mjs","type":"module","_from":"file:plugdash-socialcard-0.1.2.tgz","types":"./dist/index.d.mts","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./card":{"types":"./dist/card.d.mts","import":"./dist/card.mjs"},"./sandbox":{"import":"./dist/sandbox-entry.mjs"}},"scripts":{"lint":"oxlint .","test":"vitest run","build":"tsdown src/index.ts --dts.eager && tsdown src/sandbox-entry.ts --dts.eager --no-clean && tsdown src/card.ts --dts.eager --no-clean","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:837246c0-c991-4727-ae60-4cdf482fcc3f"}},"_resolved":"/tmp/1ae81d3ba905d402039af17e8db51765/plugdash-socialcard-0.1.2.tgz","_integrity":"sha512-ye57MVtTMf/pIuV88hAkPR/0VrUopYGvZIYHz/o9dfCde5nk3jQY8c9MPk09kpm7H8iEdqatt6qv1gmukBy3ew==","repository":{"url":"git+https://github.com/plugdash/plugdash.git","type":"git","directory":"packages/socialcard"},"_npmVersion":"11.5.1","description":"OG social card generation for EmDash - builds a share image on publish and writes it to metadata.ogImage","directories":{},"_nodeVersion":"22.23.2","_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.0.0","@plugdash/types":"0.0.0","@plugdash/testing":"0.0.0"},"peerDependencies":{"emdash":">=0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/socialcard_0.1.2_1790409482094_0.14199589698174053","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"_id":"@plugdash/socialcard@0.2.0","bugs":{"url":"https://github.com/plugdash/plugdash/issues"},"dist":{"shasum":"429c9ec49daafeee93711e1f20a5d97c65680b27","tarball":"https://registry.npmjs.org/@plugdash/socialcard/-/socialcard-0.2.0.tgz","fileCount":14,"integrity":"sha512-+Mbx8y5YFpYg/miaqcQmofcWvzQCzOXBbtwjMu2Upk9wcGPiXa3bzI1JGs6m9jHImUN+k42KI7lzCflFw80p0A==","signatures":[{"sig":"MEQCIBTaD/zacmBW3XJD+xg/Q7VsPF+YfHJro+RnRJM5wodUAiAb9uD+yw/gb2B49UPpZjNvm3UZxZyHbqlrlLGQpFGZnw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIF40Ly9EZP0trFf2FIK8yGsOMIpNnDG5c1lGcpnHr7oWAiEA5pYlhIMIsl6EKGfi4LpRQLtmRdwNmEGEuv754aViuGk="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@plugdash%2fsocialcard@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":193215},"main":"./dist/index.mjs","name":"@plugdash/socialcard","type":"module","_from":"file:plugdash-socialcard-0.2.0.tgz","types":"./dist/index.d.mts","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./card":{"types":"./dist/card.d.mts","import":"./dist/card.mjs"}},"license":"MIT","scripts":{"lint":"oxlint .","test":"vitest run","build":"tsdown src/index.ts src/card.ts --dts.eager","typecheck":"tsc --noEmit"},"version":"0.2.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"837246c0-c991-4727-ae60-4cdf482fcc3f"}},"homepage":"https://github.com/plugdash/plugdash#readme","keywords":["emdash","emdash-plugin","og-image","open-graph","png","social-sharing","socialcard"],"_resolved":"/tmp/4bd55dc916b803065af375f1902ec437/plugdash-socialcard-0.2.0.tgz","_integrity":"sha512-+Mbx8y5YFpYg/miaqcQmofcWvzQCzOXBbtwjMu2Upk9wcGPiXa3bzI1JGs6m9jHImUN+k42KI7lzCflFw80p0A==","repository":{"url":"git+https://github.com/plugdash/plugdash.git","type":"git","directory":"packages/socialcard"},"_npmVersion":"11.5.1","description":"Share images for EmDash posts - renders a PNG card on publish and sets it as the post's SEO image","directories":{},"maintainers":[{"name":"abhinav061","email":"abhinav061@gmail.com"}],"_nodeVersion":"22.23.3","dependencies":{"@resvg/resvg-wasm":"^2.6.2"},"_hasShrinkwrap":false,"devDependencies":{"emdash":"^1.0.1","vitest":"^2.0.0","@types/node":"^22.20.5","@plugdash/types":"0.0.0","@plugdash/testing":"0.0.0"},"peerDependencies":{"emdash":">=1.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/socialcard_0.2.0_1790936772303_0.18496991323668177"}}},"time":{"created":"2026-09-26T05:18:01.406Z","modified":"2026-10-02T10:26:12.848Z","0.1.0":"2026-09-26T05:18:01.744Z","0.1.1":"2026-09-26T06:29:54.627Z","0.1.2":"2026-09-26T07:58:02.173Z","0.2.0":"2026-10-02T10:26:12.426Z"},"bugs":{"url":"https://github.com/plugdash/plugdash/issues"},"license":"MIT","homepage":"https://github.com/plugdash/plugdash#readme","keywords":["emdash","emdash-plugin","og-image","open-graph","png","social-sharing","socialcard"],"repository":{"url":"git+https://github.com/plugdash/plugdash.git","type":"git","directory":"packages/socialcard"},"description":"Share images for EmDash posts - renders a PNG card on publish and sets it as the post's SEO image","maintainers":[{"name":"abhinav061","email":"abhinav061@gmail.com"}],"readme":"# @plugdash/socialcard\n\n**@plugdash/socialcard** - posts shared on X, LinkedIn, Slack or Facebook show up as a bare link when they have no share image. On publish, this plugin draws a 1200x630 PNG card with the post title, author and date, stores it in your media library, and sets it as the post's SEO image. Your template's existing `og:image` tag picks it up with no template changes. The EmDash equivalent of Social Image Generator / Yoast's OG image feature.\n\n## Install\n\n```bash\npnpm add @plugdash/socialcard\n```\n\n## Register\n\nIt is a native plugin, so it goes in `plugins`, not `sandboxed`.\n\n```js\n// astro.config.mjs\nimport { defineConfig } from \"astro/config\";\nimport emdash from \"emdash/astro\";\nimport { socialcardPlugin } from \"@plugdash/socialcard\";\n\nexport default defineConfig({\n\tintegrations: [\n\t\temdash({\n\t\t\tplugins: [socialcardPlugin()],\n\t\t}),\n\t],\n});\n```\n\n## How it works\n\n1. You publish a post (or a page, or any collection with SEO enabled).\n2. After the publish response goes out, the plugin builds the card as SVG and rasterises it to PNG with [resvg-wasm](https://github.com/yisibl/resvg-js).\n3. The PNG is uploaded as `og-<id>.png` (`image/png`) through `ctx.media.upload`, so it lives wherever your media lives (local `uploads/`, R2, S3).\n4. The plugin sets the entry's `seo.image` to the media URL, for example `/_emdash/api/media/file/01M3....png`. This is an SEO-only update: it goes live at once and does not create a draft.\n5. `getSeoMeta()` turns that root-relative path into an absolute URL using the `siteUrl` you pass it. The blog template passes `Astro.url.origin`, so `og:image` always matches the host the page was served from. `EmDashHead` then writes the `og:image` and `twitter:image` tags.\n\nIf your template does not use `getSeoMeta()`, read `post.seo.image` and prefix it with `Astro.url.origin`.\n\n### What it skips\n\n- **Unchanged posts.** The plugin hashes title, author, publish date, your config and the plugin version, and keeps the hash in KV. Re-publishing without a change logs `card unchanged, skipping render` and does nothing else.\n- **Autosaves and draft saves.** Only `content:afterPublish` is hooked.\n- **A hand-set SEO image.** If someone sets `seo.image` in the admin, the plugin leaves it alone unless you pass `overwriteSeoImage: true`.\n- **Collections without SEO support.** Logged once per collection, then ignored.\n\nWhen a card is redrawn (say the title changed), the new PNG is uploaded first and the old media item is deleted, so cards do not pile up in your media library.\n\n## Configuration\n\n```js\nsocialcardPlugin({\n\ttemplate: \"bold\",\n\tbackground: \"#111827\",\n\tforeground: \"#fef3c7\",\n\tlogo: \"https://example.com/logo.png\",\n});\n```\n\n| Option            | Type                                   | Default     | Description                                                  |\n| ----------------- | -------------------------------------- | ----------- | ------------------------------------------------------------ |\n| template          | `\"default\"` \\| `\"minimal\"` \\| `\"bold\"` | `\"default\"` | Card layout                                                  |\n| width             | `number`                               | `1200`      | Card width in pixels                                         |\n| height            | `number`                               | `630`       | Card height in pixels                                        |\n| background        | `string` (hex)                         | `\"#0f172a\"` | Background colour                                            |\n| foreground        | `string` (hex)                         | `\"#f8fafc\"` | Text (and, on `minimal`, paper) colour                       |\n| logo              | `string`                               | none        | Logo in the top-left corner: http(s) URL or file path (Node) |\n| fontFiles         | `string[]`                             | none        | Extra TTF/OTF fonts: http(s) URLs or file paths (Node)       |\n| overwriteSeoImage | `boolean`                              | `false`     | Replace an SEO image someone set by hand                     |\n\nChanging any option changes the hash, so every post gets a new card on its next publish.\n\n## Templates\n\n- `default` - large title, author and date byline, subtle gradient\n- `minimal` - title only, clean paper background\n- `bold` - large type against a strong colour block\n\nLong titles (over 80 characters) are cut with an ellipsis. The author comes from a `data.author` field (string or `{ name }`), then the post's primary byline. A missing author or date drops that half of the byline.\n\n## Fonts\n\nThe package bundles Lexend Regular and Bold, Latin subset (about 24 KB each, SIL Open Font License, see `OFL-Lexend.txt`). Titles in other scripts need a font that has those glyphs, or they render as empty boxes. Add one with `fontFiles`; it is used as a fallback for any character Lexend does not have:\n\n```js\nsocialcardPlugin({\n\t// Hindi titles\n\tfontFiles: [\"./fonts/NotoSansDevanagari-Bold.ttf\"],\n});\n```\n\nUse a file path on Node, or an http(s) URL on any runtime. Prefer a subset or a single weight: the font is loaded on every render.\n\n## Performance\n\nMeasured on Node 24, Apple M-series, default 1200x630:\n\n- First render after a server start: about 80-110 ms (includes compiling the WASM module)\n- Later renders: about 20-45 ms\n- PNG size: about 310-340 KB for `default` (the gradient does not compress well), about 37 KB for `minimal`, about 56 KB for `bold`\n\nThe work runs after the publish response, so editors do not wait for it. The hook timeout is 30 seconds, mostly to bound a slow logo or font fetch.\n\nresvg and the fonts are loaded with `await import()` inside the hook. A normal page request never loads them.\n\n## What it does not do\n\n- Does not write `metadata.ogImage` any more (0.1.x did). Use `seo.image`.\n- Does not draw cards for drafts or on autosave\n- Does not delete the card when a post is unpublished\n- Does not fetch Google Fonts by name. Pass a font file with `fontFiles`.\n- Has no admin page. Configure it in `astro.config.mjs`.\n\n## Cloudflare Workers\n\nThe Workers path is not verified yet. workerd does not allow compiling WASM from bytes, so on Workers the plugin imports `@resvg/resvg-wasm/index_bg.wasm?module` and expects the bundler to hand it a compiled module. File paths in `logo` and `fontFiles` do not work there; use URLs.\n","readmeFilename":"README.md"}