Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
og-images-generator
Advanced tools
Generate OG images from a static folder. Extract metadata from HTML pages. No headless browser involved.
Generate OG images from a static folder. Extract metadata from HTML pages. No headless browser involved.
npm i og-images-generator
Create a og-images.config.js
in your current workspace root.
See demos/vanilla/og-images.config.js for a full working example.
The gist is:
// ./og-images.config.js
import {
html,
styled,
OG_DIMENSIONS,
SOURCE_SANS_FONT,
} from 'og-images-generator';
/** @type {import('og-images-generator').RenderOptions} */
export const renderOptions = {
satori: { fonts: [await SOURCE_SANS_FONT()], ...OG_DIMENSIONS },
};
/** @type {import('og-images-generator').Template} */
export const template = ({ metadata }) => {
if ('og:title' in metadata === false) throw Error('Missing title!');
if ('og:description' in metadata === false)
throw Error('Missing description!');
const title = metadata['og:title'];
const description = metadata['og:description'];
return html` <!-- -->
<div style=${styles.container}>
<div style=${styles.foo}>
${icon.main}
<!-- ... -->
</div>
</div>`;
};
const tokens = {
primaryColor: `rgb(82,245,187)`,
};
const icons = {
main: html`
<svg>
<!-- ... -->
</svg>
`,
};
const styles = {
container: styled.div`
display: flex;
height: 100%;
width: 100%;
/* ... */
`,
foo: styled.div`
display: flex;
color: ${tokens.primaryColor};
/* ... */
`,
};
You need to export renderOptions
and template
from your og-images-generator
configuration file.
[!NOTE]
styled.div
is a dummy strings concatenation literal (to get syntax highlighting).
div
is the only needed (and available) tag, as it makes no difference anyway.Also, you don't need to wrap interpolated HTML attributes with quotes (e.g.
style="${foo}"
).
<foo-bar style=${styles.baz}></foo-bar>
just works.
[!TIP]
Recommended VS Code extensions:
- Styled Components for inline CSS highlighting:
styled-components.vscode-styled-components
- HTML highlighting:
bierner.lit-html
npx generate-og
# defaults to
npx generate-og --base dist --out dist/og --json dist/og/index.json
import { generateOgImages } from 'og-images-generator/api';
await generateOgImages(/* options */);
Other projects 👀…
github
→ ✅ GitHub
.FAQs
Generate OG images from a static folder and / or a middleware. Extract metadata from HTML pages. No headless browser involved. Comes as a CLI, API or plugins.
We found that og-images-generator demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.