
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
gatsby-plugin-ogi
Advanced tools
Build dynamic open-graph preview images for gatsby pages. Simply use react components to create SEO ready preview images for Twitter, Facebook, Linkedin, Google, and many more.
A Gatsby plugin to derive and generated Images for the Open Graph Protocol directly from React Components.
yarn add gatsby-plugin-open-graph-images
or npm i gatsby-plugin-open-graph-images
gatsby-config.js
:plugins: [`gatsby-plugin-open-graph-images`];
The creation of Open Graph images is done by createOpenGraphImage()
within your gatsby-node.js
file.
exports.createPages = async ({ actions }) => {
const { createPage } = actions;
const openGraphImage = createOpenGraphImage(createPage, {
path: "/og-image/index.png",
component: path.resolve(`src/templates/index.og-image.js`),
size: {
width: 400,
height: 50,
},
context: {
description: "a image created with gatsby-plugin-open-graph-images",
},
});
};
You can than simply include your open-graph image within your page. For example by using react-helmet:
<Helmet>
<meta property="og:image" content={domain + "/og-image/index.png"} />
<meta property="og:image:width" content="400" />
<meta property="og:image:width" content="50" />
</Helmet>
A more advanced usage of createOpenGraphImage()
is described in this dev.to article.
option | type | description |
---|---|---|
defaultSize | optional | The default size for the generated image if not explicitly specified. default: { width: 1200, height: 630} |
componentGenerationDir | optional | The directory where the rendered gatsby components are temporarily stored, to be later saved as images default: "__generated" |
If you use plugins that iterate over your pages, like gatsby-plugin-sitemap
, exclude the componentGenerationDir
:
{
resolve: `gatsby-plugin-sitemap`,
options: {
exclude: [`/__generated/*`],
},
},
FAQs
Build dynamic open-graph preview images for gatsby pages. Simply use react components to create SEO ready preview images for Twitter, Facebook, Linkedin, Google, and many more.
We found that gatsby-plugin-ogi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.