npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@andrioid/gatsby-plugin-social-card

v0.5.6

Published

Generates social cards for your markdown posts and adds a field so you can reference them in your meta-tags.

Downloads

8

Readme

gatsby-plugin-social-card

Automatically parses your posts and generates social cards for Twitter, Slack, Facebook and other sites.

To learn more about social-cards in general, check out open graph, twitter cards and this CSS tricks article on meta-tags for social.

Current Status: Beta

I'm using this for andri.dk and it works for me, both locally and for Netlify builds. Contact me on Twitter if you're testing this and it fails.

Only works for remark nodes at the moment.

Features

Designs

There are two design available now, "card" and "default". But we can expand that later.

default card design

default card design

default card design

Custom Backgrounds

You can put a cover frontmatter on your post, and we'll use that. Otherwise, we'll use a default-background that you can specify or if that fails, we'll use a fallback one.

Custom Author image

If specified, an author image is shown on the image. That is also configurable.

Powerd by SVG, React and Sharp

We use the same underlying library that powers gatsby-images to convert our React generated SVG files into images.

Install

yarn add @andrioid/gatsby-plugin-social-card
# or npm install --save @andrioid/gatsby-plugin-social-card

How to use

Configure our site to use the plugin by editing gatsby-config.js. You don't need to specify options.

plugins: [
	{
		'@andrioid/gatsby-plugin-social-card',
	}
]

If you want to customise the look of the cards, try these options.

plugins: [
	{
		resolve: '@andrioid/gatsby-plugin-social-card',
		options: {
			// ommit to skip
			authorImage: './static/img/coffee-art.jpg',
			// image to use when no cover in frontmatter
			backgroundImage: './static/img/hvitserkur.JPG',
			// author to use when no auth in frontmatter
			defaultAuthor: 'Andri Óskarsson',
			// card design
			design: 'default' // 'default' or 'card'
		}
	}
]

Then you need to add the meta tags to your site. For a more complete example of meta tags, check out seo.js from Kent C. Dodds.

import Helmet from 'react-helmet'

const image = node.frontmatter.socialcard

export const SEO = ({ postData, frontmatter = {}, metaImage, isBlogPost }) => (
	<Helmet>
		{/* Your other meta tags... */}
		<meta name="image" content={image} />
		<meta property="og:image" content={image} />
		<meta name="twitter:card" content="summary_large_image">
		<meta name="twitter:image" content={image} />
	</Helmet>
)

Pitfalls

Fonts

We use sharp to convert our SVG images to JPG. The means that the fonts available to you are limited to those of the build-machine.

VIPS image library

Depending on your installation, SVG support in libvips (used by Sharp) might be missing.

It needs to be built with JPEG and SVG support.