
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
gatsby-plugin-open-graph-images
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,
},
waitCondition: "networkidle0",
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.
The npm package gatsby-plugin-open-graph-images receives a total of 5 weekly downloads. As such, gatsby-plugin-open-graph-images popularity was classified as not popular.
We found that gatsby-plugin-open-graph-images 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
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.