{"_id":"@altano/astro-opengraph-image","_rev":"5-d6f1a9586d7e2216ca5595150a2ebe4c","name":"@altano/astro-opengraph-image","dist-tags":{"latest":"0.0.1-alpha.5"},"versions":{"0.0.1-alpha.2":{"name":"@altano/astro-opengraph-image","version":"0.0.1-alpha.2","keywords":["astro","withastro","middleware","astro-integration"],"author":{"url":"https://alan.norbauer.com","name":"Alan Norbauer","email":"altano@gmail.com"},"license":"ISC","_id":"@altano/astro-opengraph-image@0.0.1-alpha.2","maintainers":[{"name":"altano","email":"altano@gmail.com"}],"homepage":"https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph-image","bugs":{"url":"https://github.com/altano/npm-packages/issues"},"dist":{"shasum":"1f5f66af08602dbd88c7daf54cd22e79ac028e20","tarball":"https://registry.npmjs.org/@altano/astro-opengraph-image/-/astro-opengraph-image-0.0.1-alpha.2.tgz","fileCount":5,"integrity":"sha512-xrV9N+AiRKSH6kjQuahmoTLXT5w1tlS3VFCz/xa08ZamcVq+AfK3B9AIP8X25xkCrG0s+EGCEOhZcJtO025/4w==","signatures":[{"sig":"MEQCID7B/gPmcdXZPwxAkFuwv7JRERZYjJsCvjWUoXA9W689AiA6tBRimpwf3DKmkOxi6k7V6g3RIZiJPskc/4j/CzMuAg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12282},"type":"module","_from":"file:altano-astro-opengraph-image-0.0.1-alpha.2.tgz","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./components/meta.astro":"./components/meta.astro"},"scripts":{"dev":"tsup src/index.ts src/endpoint.ts --watch --format esm","lint":"eslint src/**/*.ts*","test":"vitest --run","build":"tsup src/index.ts src/endpoint.ts --format esm --dts --onSuccess \"pnpm build:types\"","clean":"rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist","format":"prettier --write src","lint:fix":"TIMING=1 eslint src/**/*.ts* --fix","test:watch":"vitest","build:types":"tsc --emitDeclarationOnly --declaration","lint:timing":"TIMING=1 eslint src/**/*.ts*"},"_npmUser":{"name":"altano","email":"altano@gmail.com"},"_resolved":"/private/var/folders/b2/jwtfxknj2sb_1xh_c60vxqrh0000gn/T/ca8c00ed4ff2d7db693f79be71de454a/altano-astro-opengraph-image-0.0.1-alpha.2.tgz","_integrity":"sha512-xrV9N+AiRKSH6kjQuahmoTLXT5w1tlS3VFCz/xa08ZamcVq+AfK3B9AIP8X25xkCrG0s+EGCEOhZcJtO025/4w==","repository":{"url":"git+https://github.com/altano/npm-packages.git","type":"git","directory":"packages/astro-opengraph-image"},"_npmVersion":"9.5.1","description":"Render Open Graph Images from Astro Components","directories":{},"sideEffects":false,"_nodeVersion":"18.16.1","dependencies":{"@altano/astro-html-to-image":"0.0.1-alpha.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.2.0","vite":"^4.4.9","vitest":"^0.34.2","@vitest/ui":"^0.30.1","typescript":"^5.1.6","@altano/assets":"^0.0.0","@altano/tsconfig":"0.0.0","jest-image-snapshot":"^6.2.0","@types/jest-image-snapshot":"^6.2.0"},"peerDependencies":{"astro":"2.x"},"_npmOperationalInternal":{"tmp":"tmp/astro-opengraph-image_0.0.1-alpha.2_1692499935942_0.24738223858764896","host":"s3://npm-registry-packages"},"deprecated":"Use @altano/astro-opengraph instead"},"0.0.1-alpha.3":{"name":"@altano/astro-opengraph-image","version":"0.0.1-alpha.3","keywords":["astro","withastro","middleware","astro-integration"],"author":{"url":"https://alan.norbauer.com","name":"Alan Norbauer","email":"altano@gmail.com"},"license":"ISC","_id":"@altano/astro-opengraph-image@0.0.1-alpha.3","maintainers":[{"name":"altano","email":"altano@gmail.com"}],"homepage":"https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph-image","bugs":{"url":"https://github.com/altano/npm-packages/issues"},"dist":{"shasum":"e036009612e61f804283357c2d7c9b48bbc912b7","tarball":"https://registry.npmjs.org/@altano/astro-opengraph-image/-/astro-opengraph-image-0.0.1-alpha.3.tgz","fileCount":17,"integrity":"sha512-cai+nmU9JDpv5va8TYZyRfPMyKTH/30R9s7KSR1uB3YFfbSdqM3y/omtvfOQhN8tCwrpbM0SdgGP8ZC+CN6krg==","signatures":[{"sig":"MEUCIDtsnG+FkPNr9VNE3cL3Q54aEOvpTQVaEJysvb9IQX/ZAiEA9stlKMFy/I1x12Gj/JuQ4k8F2fqHXHuWv+fNFbouJ7k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15485},"type":"module","_from":"file:altano-astro-opengraph-image-0.0.1-alpha.3.tgz","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./components/meta.astro":"./components/meta.astro"},"scripts":{"dev":"tsup src/index.ts src/endpoint.ts --watch --format esm","lint":"eslint src/**/*.ts*","test":"vitest --run","build":"tsup src/index.ts src/endpoint.ts --format esm --dts --onSuccess \"pnpm build:types\"","clean":"rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist","format":"prettier --write src","lint:fix":"TIMING=1 eslint src/**/*.ts* --fix","test:watch":"vitest","build:types":"tsc --emitDeclarationOnly --declaration","lint:timing":"TIMING=1 eslint src/**/*.ts*"},"_npmUser":{"name":"altano","email":"altano@gmail.com"},"_resolved":"/private/var/folders/b2/jwtfxknj2sb_1xh_c60vxqrh0000gn/T/2e3e0d0da23fdec6197c6853e9411117/altano-astro-opengraph-image-0.0.1-alpha.3.tgz","_integrity":"sha512-cai+nmU9JDpv5va8TYZyRfPMyKTH/30R9s7KSR1uB3YFfbSdqM3y/omtvfOQhN8tCwrpbM0SdgGP8ZC+CN6krg==","repository":{"url":"git+https://github.com/altano/npm-packages.git","type":"git","directory":"packages/astro-opengraph-image"},"_npmVersion":"9.5.1","description":"Render Open Graph Images from Astro Components","directories":{},"sideEffects":false,"_nodeVersion":"18.16.1","dependencies":{"@altano/astro-html-to-image":"0.0.1-alpha.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.2.0","vite":"^4.4.9","vitest":"^0.34.2","@vitest/ui":"^0.30.1","typescript":"^5.1.6","@altano/assets":"^0.0.0","@altano/tsconfig":"0.0.0","jest-image-snapshot":"^6.2.0","@types/jest-image-snapshot":"^6.2.0"},"peerDependencies":{"astro":"2.x"},"_npmOperationalInternal":{"tmp":"tmp/astro-opengraph-image_0.0.1-alpha.3_1692501562152_0.8892631865606522","host":"s3://npm-registry-packages"},"deprecated":"Use @altano/astro-opengraph instead"},"0.0.1-alpha.4":{"name":"@altano/astro-opengraph-image","version":"0.0.1-alpha.4","keywords":["astro","withastro","middleware","astro-integration"],"author":{"url":"https://alan.norbauer.com","name":"Alan Norbauer","email":"altano@gmail.com"},"license":"ISC","_id":"@altano/astro-opengraph-image@0.0.1-alpha.4","maintainers":[{"name":"altano","email":"altano@gmail.com"}],"homepage":"https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph-image","bugs":{"url":"https://github.com/altano/npm-packages/issues"},"dist":{"shasum":"7647a6f699c25557f627479dae4d8ebd53fce65c","tarball":"https://registry.npmjs.org/@altano/astro-opengraph-image/-/astro-opengraph-image-0.0.1-alpha.4.tgz","fileCount":17,"integrity":"sha512-4JA9KFxiGfi0jVRVTWfr5FSNsVCVvwstD2+kdgPEVzzyJqMl1Gx0ooA5dDI2tzP+51KNtAuwXvJ3afv8Vcnqqw==","signatures":[{"sig":"MEUCIBZQHANftSFCbaViRQ9+ga4rbqjrZ45TuUnzG1H2NbDuAiEArSkH3SOSFuIM9RwrXsvIZ4p32gsUhlaOxLAlE9Yxkec=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15509},"type":"module","_from":"file:altano-astro-opengraph-image-0.0.1-alpha.4.tgz","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./components/meta.astro":"./components/meta.astro"},"scripts":{"dev":"tsup src/index.ts src/endpoint.ts --watch --format esm","lint":"eslint src/**/*.ts*","test":"vitest --run","build":"tsup src/index.ts src/endpoint.ts --format esm --dts --onSuccess \"pnpm build:types\"","clean":"rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist","format":"prettier --write src","lint:fix":"TIMING=1 eslint src/**/*.ts* --fix","test:watch":"vitest","build:types":"tsc --emitDeclarationOnly --declaration","lint:timing":"TIMING=1 eslint src/**/*.ts*"},"_npmUser":{"name":"altano","email":"altano@gmail.com"},"_resolved":"/private/var/folders/b2/jwtfxknj2sb_1xh_c60vxqrh0000gn/T/11740c3bf154d7099fc3395a9fce119b/altano-astro-opengraph-image-0.0.1-alpha.4.tgz","_integrity":"sha512-4JA9KFxiGfi0jVRVTWfr5FSNsVCVvwstD2+kdgPEVzzyJqMl1Gx0ooA5dDI2tzP+51KNtAuwXvJ3afv8Vcnqqw==","repository":{"url":"git+https://github.com/altano/npm-packages.git","type":"git","directory":"packages/astro-opengraph-image"},"_npmVersion":"9.5.1","description":"Render Open Graph Images from Astro Components","directories":{},"sideEffects":false,"_nodeVersion":"18.16.1","dependencies":{"@altano/astro-html-to-image":"0.0.1-alpha.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.2.0","vite":"^4.4.9","astro":"^3.0.13","vitest":"^0.34.3","@vitest/ui":"^0.30.1","typescript":"^5.1.6","@altano/assets":"^0.0.0","@altano/tsconfig":"0.0.0","jest-image-snapshot":"^6.2.0","@types/jest-image-snapshot":"^6.2.0"},"peerDependencies":{"astro":"3.x"},"_npmOperationalInternal":{"tmp":"tmp/astro-opengraph-image_0.0.1-alpha.4_1694568665760_0.7051229801376795","host":"s3://npm-registry-packages"},"deprecated":"Use @altano/astro-opengraph instead"},"0.0.1-alpha.5":{"name":"@altano/astro-opengraph-image","version":"0.0.1-alpha.5","keywords":["astro","withastro","middleware","astro-integration"],"author":{"url":"https://alan.norbauer.com","name":"Alan Norbauer","email":"altano@gmail.com"},"license":"ISC","_id":"@altano/astro-opengraph-image@0.0.1-alpha.5","maintainers":[{"name":"altano","email":"altano@gmail.com"}],"homepage":"https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph-image","bugs":{"url":"https://github.com/altano/npm-packages/issues"},"dist":{"shasum":"c7487c15ef3e3df3aa81d775e5477db57d89549e","tarball":"https://registry.npmjs.org/@altano/astro-opengraph-image/-/astro-opengraph-image-0.0.1-alpha.5.tgz","fileCount":11,"integrity":"sha512-pdOdxx3eEf/jPhoK8RCpEFYQ2DCcrUab+NW8pxE8qd0p8EU/KFSSWb1OHDhK2LFvq4D2T17ImDekwNwxB9oZBQ==","signatures":[{"sig":"MEUCIQDb60j+M8KPMZhk6sZ3neTlYb7UPn83zYlQLm5KmdupbwIgYCeTyq2/bZX2ZHMrMffyTnBPz3nyYKRC/y+FQa5i/sg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17139},"type":"module","_from":"file:altano-astro-opengraph-image-0.0.1-alpha.5.tgz","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./middleware":"./dist/middleware.js","./components/meta.astro":"./components/meta.astro"},"scripts":{"dev":"tsup --watch","lint":"eslint src/**/*.ts*","test":"vitest --run","build":"tsup","clean":"rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist","format":"prettier --write src","lint:fix":"TIMING=1 eslint src/**/*.ts* --fix","test:watch":"vitest","build:types":"tsc --emitDeclarationOnly --declaration","lint:timing":"TIMING=1 eslint src/**/*.ts*"},"_npmUser":{"name":"altano","email":"altano@gmail.com"},"_resolved":"/private/var/folders/b2/jwtfxknj2sb_1xh_c60vxqrh0000gn/T/cfde39ff584688c061fdc2111857fdce/altano-astro-opengraph-image-0.0.1-alpha.5.tgz","_integrity":"sha512-pdOdxx3eEf/jPhoK8RCpEFYQ2DCcrUab+NW8pxE8qd0p8EU/KFSSWb1OHDhK2LFvq4D2T17ImDekwNwxB9oZBQ==","repository":{"url":"git+https://github.com/altano/npm-packages.git","type":"git","directory":"packages/astro-opengraph-image"},"_npmVersion":"9.8.1","description":"Render Open Graph Images from Astro Components","directories":{},"sideEffects":false,"_nodeVersion":"18.18.2","dependencies":{"@altano/astro-html-to-image":"0.0.1-alpha.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.2.0","vite":"^4.4.9","astro":"^4.0.7","vitest":"^1.0.4","@vitest/ui":"^1.0.4","typescript":"^5.1.6","utility-types":"^3.10.0","@altano/assets":"^0.0.0","@altano/tsconfig":"0.0.0","jest-image-snapshot":"^6.2.0","@types/jest-image-snapshot":"^6.2.0"},"peerDependencies":{"astro":">= 4.0"},"_npmOperationalInternal":{"tmp":"tmp/astro-opengraph-image_0.0.1-alpha.5_1703130310222_0.3230192644264622","host":"s3://npm-registry-packages"},"deprecated":"Use @altano/astro-opengraph instead"}},"time":{"created":"2023-08-20T02:52:15.858Z","modified":"2025-07-02T01:22:53.800Z","0.0.1-alpha.2":"2023-08-20T02:52:16.116Z","0.0.1-alpha.3":"2023-08-20T03:19:22.370Z","0.0.1-alpha.4":"2023-09-13T01:31:05.982Z","0.0.1-alpha.5":"2023-12-21T03:45:10.385Z"},"bugs":{"url":"https://github.com/altano/npm-packages/issues"},"author":{"url":"https://alan.norbauer.com","name":"Alan Norbauer","email":"altano@gmail.com"},"license":"ISC","homepage":"https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph-image","keywords":["astro","withastro","middleware","astro-integration"],"repository":{"url":"git+https://github.com/altano/npm-packages.git","type":"git","directory":"packages/astro-opengraph-image"},"description":"Render Open Graph Images from Astro Components","maintainers":[{"name":"altano","email":"altano@gmail.com"}],"readme":"> ⚠️ **WORK IN PROGRESS**: This package requires changes[^filename-change] in Astro before it will be useable. Sit tight!\n\n# astro-opengraph-image\n\nThis is an [Astro integration](https://docs.astro.build/en/guides/integrations-guide/) that lets you turn any Astro component (or framework component) into an Open Graph image for your Astro site.\n\nUnlike existing Astro integrations for Open Graph images, this one:\n\n- Doesn't require any out-of-band screenshotting. It's all Astro native, so to speak.\n- Can turn ANY component into an Open Graph image. You're in full control of the html/css.\n\n# Prerequisites\n\n- This integration is for [Astro](https://astro.build).\n\n# Installation\n\nIn your existing Astro project:\n\n```sh\n# Using NPM\nnpx astro add @altano/astro-opengraph-image\n# Using Yarn\nyarn astro add @altano/astro-opengraph-image\n# Using PNPM\npnpm astro add @altano/astro-opengraph-image\n```\n\n# Configuration\n\nYou'll need to configure the integration in your Astro config. At the very least, you must provide some fonts to use (as there are no defaults).\n\n```ts\nexport default defineConfig({\n  integrations: [\n    opengraphImage({\n      async getSvgOptions() {\n        return {\n          fonts: [...],\n        };\n      },\n    }),\n  ],\n});\n```\n\nCreate a component to convert to an image. It must have a `.png.astro` extension, e.g. `image.png.astro`:\n\n```astro\n<html><body>Hello!</body></html>\n```\n\nNOTE: Your Astro component must be HTML elements and styles [supported by Satori](https://github.com/vercel/satori#jsx), e.g. it can't be stateful or use `calc()` in css. The [OG Image Playground](https://og-playground.vercel.app/) is a great place to test your component before copying it into your Astro project.\n\nLastly, in any pages/layouts that have a `opengraph-image.png.astro` in that route, you need to add the `<OpenGraphMeta />` component to generate opengraph meta tags in your head, e.g.:\n\n```astro\n---\nimport OpenGraphMeta from \"@altano/astro-opengraph-image/components/meta.astro\";\n---\n\n<html>\n  <head>\n    <OpenGraphMeta />\n  </head>\n  <body>\n    <p>My opengraph-image should be the root one!</p>\n  </body>\n</html>\n```\n\n# Options Reference\n\nThe integration requires the following options:\n\n- `getSvgOptions.fonts`: an array of fonts that will be used in your image component. Each font requires:\n  - `name`: This is whatever you reference in your css, e.g. `Inter`\n  - `path`: A string path to your font file. Can be in your node_modules folder, e.g. `\"node_modules/@fontsource/inter/files/inter-latin-400-normal.woff\"`\n  - `weight`: A weight, from 100 to 900. You can provide different fonts for different weights.\n\nSee the TypeScript type-hints and comments for more info.\n\n# Examples\n\n## Using custom fonts\n\n`astro.config.mts`:\n\n```ts\nimport { defineConfig } from \"astro/config\";\nimport opengraphImage from \"@altano/astro-opengraph-image\";\n\n// https://astro.build/config\nexport default defineConfig({\n  integrations: [\n    opengraphImage({\n      async getSvgOptions() {\n        return {\n          fonts: [\n            {\n              name: \"Inter\",\n              path: \"node_modules/@fontsource/inter/files/inter-latin-400-normal.woff\",\n              weight: 400,\n              style: \"normal\",\n            },\n            {\n              name: \"Inter\",\n              path: \"node_modules/@fontsource/inter/files/inter-latin-800-normal.woff\",\n              weight: 800,\n              style: \"normal\",\n            },\n          ],\n        };\n      },\n    }),\n  ],\n});\n```\n\n`src/pages/opengraph-image.png.astro`:\n\n```astro\n---\n/**\n * This is not used during image generation. It is only here\n * to make the fonts consistent between the generated image\n * and how the component is rendered if the image generation\n * middleware is disabled.\n */\nimport \"@fontsource-variable/inter\";\n---\n\n<html>\n  <body\n    style=`font-family: \"Inter Variable\";\n           background: white;\n           height: 100vh;\n           width: 100vw;\n           display: flex;\n           flex-direction: column;\n           align-items: center;\n           justify-content: center;`\n  >\n    <h1\n      style=\"font-weight: 800;\n             font-size: 5rem;\n             margin: 0;\"\n    >\n      My Website!\n    </h1>\n    <p style=\"font-weight: 400;\n              font-size: 2rem;\">\n      This is rendered as a PNG image.\n    </p>\n  </body>\n</html>\n```\n\n`src/pages/index.astro`\n\n```astro\n<html>\n  <head>\n    <title>Homepage</title>\n    <OpenGraphMeta title=\"My Website\" description=\"This is a website.\" />\n  </head>\n  <body>\n    ...\n  </body>\n</html>\n```\n\nSee https://github.com/altano/npm-packages/tree/main/examples/astro-opengraph-image for a slightly more involved example.\n\n## Serving another opengraph-image\n\nIf your `opengraph-image.png.astro` is somewhere else, you can specify a directory relative to the current request URL, e.g. to point at an `opengraph-image.png.astro` file you've put at the root of your site:\n\n```astro\n<html>\n  <head>\n    <title>My opengraph image is at the site root</title>\n    <OpenGraphMeta directory=\"/\" />\n  </head>\n</html>\n```\n\n## Adding title/description\n\nLastly, for convenience, you can optionally pass in `title` and/or `description` to get the `og:title` and `og:description` meta tags:\n\n```astro\n<OpenGraphMeta title=\"Nope\" description=\"I'm not important\" />\n```\n\n## Dynamic Routes\n\nIf you have a dynamic route such as `./src/pages/[...slug].astro`, convert it to `./src/pages/[...slug]/index.astro`\n\nAlong-side your dynamic route (e.g. `./src/pages/[...slug]/index.astro`) add `./src/pages/[...slug]/opengraph-image.png.astro`:\n\n```\nsrc/\n├─ pages/\n│  ├─ [...slug]/\n│  │  ├─ index.astro\n│  │  ├─ opengraph-image.png.astro\n```\n\nWithin `opengraph-image.png.astro` you can either duplicate your implementation of `getStaticPaths` or you can re-export the same one used in `index.astro`:\n\n```astro\n---\nimport { getStaticPaths as gsp } from \"./index.astro\";\nexport const getStaticPaths = gsp;\n---\n```\n\n# How it Works\n\nThis library is a tiny wrapper around [@altano/astro-html-to-image](https://github.com/altano/npm-packages/tree/main/packages/astro-html-to-image) which can convert any html response in Astro into an image.\n\n[^filename-change]: https://github.com/withastro/roadmap/discussions/643\n[^middleware-docs]: https://docs.astro.build/guides/middleware\n","readmeFilename":"README.md"}