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

real-og

v0.0.8

Published

Generates og:image social card images for Markdown files based on an HTML+CSS template

Downloads

3

Readme

real-og

If you need a thing to generate social media og:image social card images from the markdown pages on your static site, then this library may help you piece together a script to do so.

Usage

const realOg = require('real-og')

// Async function, returns a promise
realOg('posts/my-post.md', 'img/my-post.png', {

  // Will be parsed as an EJS template and passed the following object:
  //   `data` - frontmatter of the markdown file
  //   `content.markdown` - Markdown below the frontmatter
  //   `content.html` - Compiled HTML of the Markdown below the frontmatter
  //   `summary.markdown` - Markdown up to the `summarySeparatory`
  //   `summary.html` - Compiled HTML up to the Markdown's `summarySeparatory`
  //   `globals.*` - Whatever you set as `globals` on this object
  template: 'template/social.html',

  // Optional options

  fileType: 'png', // jpg, gif, webp
  summarySeparator: '<!--more-->', // token that separates
  width: 1200,
  height: 630,
  globals: {
    /* Any additional stuff you want to send to the template. */
  },
  // Override the tailwind classes of elements generated by markdown
  markdownTailwindClasses: {
    p: 'mt-0 mb-6',
    h1: 'font-size-3xl',
  },
  // Override the style attribute for these markdown elements
  markdownStyleAttrs: {
    p: 'text-overflow: ellipsis',
  },
  // Remove these tags since Satori can't really handle inline text elements
  markdownUnwrapElements: ['a', 'em'],
  // Custom extensions for showdown's markdown processing.
  // See: https://github.com/showdownjs/showdown/wiki/Extensions
  markdownExtensions: [
    {
      type: 'output',
      regex: new RegExp(`<li([^>]*)>([^<]*)<\\/li>`, 'g'),
      replace: '<li$1>• $2</li>'
    }
  ],


  // At least one font is required by the satori package
  fonts: [
    {
      name: 'Source Sans Pro',
      data: fs.readFileSync(require.resolve('@fontsource/source-sans-pro/files/source-sans-pro-latin-400-normal.woff')),
      weight: 400,
      style: 'normal'
    }
  ]
})

The template can contain any of the subset of HTML and CSS supported by satori, including Tailwind classes via a tw attribute.

Acknowledgements

This package was started by adapting the meat of eleventy-plugin-og-imag into a standalone package exposing its core functionality as an API that isn't coupled to the separately-excellent 11ty

Code of Conduct

This project follows Test Double's code of conduct for all community interactions, including (but not limited to) one-on-one communications, public posts/comments, code reviews, pull requests, and GitHub issues. If violations occur, Test Double will take any action they deem appropriate for the infraction, up to and including blocking a user from the organization's repositories.