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

@francesc/gatsby-plugin-multilang-twitter-cards

v0.1.8

Published

Gatsby plugin for generating Twitter Open Graph cards

Downloads

12

Readme

gatsby-plugin-multilang-twitter-cards 🇺🇳📇

This project is forked from gatsby-remark-twitter-cards, which in turn was derived from gatsby-remark-social-cards

The main goal of this fork is to make it compatible with multi-languguage sites using gatsby-plugin-intl. To achieve this goal, a field named lang must be defined in all markdown nodes.

gatsby-plugin-multilang-twitter-cards in action

gatsby-plugin-multilang-twitter-cards is a Gatsby plugin that allows you to create individual open graph twitter card images at build time for inclusion in your site's SEO metadata. It generates cards as JPGs with embedded text in the recommended size of 1200px x 630px.

It uses the wasm-twitter-card library under the hood: by using Rust libraries compiled to WebAssembly, we can work around some of the limitations of the most popular dependency-free image editing library for Node.js, jimp.

It can be added to your plugins in gatsby-config.js like so:

  plugins: [
    // ...
    {
      resolve: `@francesc/gatsby-plugin-multilang-twitter-cards`,
      options: {
        localizedTitles: {en: 'English title', ca: 'Títol català'}, // website titles - required
        localizedAuthors: {en: 'English author', ca: 'Autor català'}, // website author names - optional
        defaultLanguage: 'en', // default language (defaults to 'en')
        separator: '|', // defaults to '|'
        background: require.resolve('./content/assets/base.jpg'), // optional path to 1200x630px file or hex code, defaults to black (#000000)
        fontColor: '#ffffff', // defaults to white (#ffffff)
        titleFontSize: 96, // defaults to 96
        subtitleFontSize: 60, // defaults to 60
        fontStyle: 'monospace', // defaults to 'monospace'
        fontFile: require.resolve('./content/assets/someFont.ttf'), // optional path to a custom TTF font - will override fontStyle
        cardFileName: 'twitter-card.jpg', // optional file name used with social cards - defaults to 'twitter-card-jpg'
      },
    },
  ],

Plugin Options

| Option | Required | Type | Default value | | ------------------ | :------: | -------------------------------------------------- | -------------------- | | localizedTitles | ✔ | object | {en: 'Untitled'} | | localizedAuthors | ✔ | object | {en: 'Mr. Gatsby'} | | defaultLanguage | ✔ | string | en | | separator | ✔ | string (character that separates title and author) | "|" | | background | ✔ | hex or file path | "#000000" | | fontColor | ✔ | hex | "#ffffff" | | titleFontSize | ✔ | int | 96 | | subtitleFontSize | ✔ | int | 60 | | fontStyle | ✔ | "monospace" or "sans-serif" | monospace | | fontFile | ✔ | path to TTF font file | | | cardFileName | ✔ | file name used when creating social cards | twitter-card.jpg |

The images will be saved in your site's /public folder, and the link to your twitter:image should be an absolute URL (something like ${siteUrl}${lang}${blogPostSlug}twitter-card.jpg) E.g. for this blog post the generated image can be found at the link https://aless.co/en/how-to-build-a-keyboard/twitter-card.jpg.

Further instructions on how to include open graph images in the metadata of your Gatsby blog can be found in the excellent documentation of the plugin that inspired this one, gatsby-remark-social-cards

Roadmap

  • [x] Custom TTF fonts 🎉
  • [x] Monospace or sans serif font
  • [x] Custom title font size
  • [x] Custom subtitle font size
  • [x] Custom font color
  • [x] Accept path to background image
  • [x] OR solid color background with hex code
  • [x] Multiple languages
  • [x] Convert the gatsby-remark plugin into a regular Gatsby plugin