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

gist-embed

v1.0.4

Published

Lightning fast zero dependency library for embedding gists on your webpage

Downloads

901

Readme

gist-embed

Lightning fast zero dependency library for embedding gists on your webpage.

Usage

Add script tag

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gist-embed.min.js"
></script>

Add code element to your webpage with data-gist-id attribute

<code data-gist-id="5457595"></code>

Global settings and init

  • You can add an object with settings to window.GistEmbedSettings before you include the gist-embed script tag
  • Settings supported:
    • baseURL: Specify a base url used to fetch the gist. Defaults to https://gist.github.com.
  • You can run the init to parse the elements at any time. This is useful when your code element is added after the script tag include has already parsed the elements on page load.
    • window.GistEmbed.init(): This will parse all the elements again that have a data-gist-id attribute.

Modifiers

You can add attributes to your HTML Element that modify the gist embed.

  • data-gist-hide-line-numbers
    • type: string ('true')
    • Removes all of the line numbers in the left hand gutter of the gist
  • data-gist-hide-footer
    • type: string ('true')
    • Removes the gist footer
  • data-gist-caption
    • type: string
    • Places a header above the gist with your chosen caption string
  • data-gist-file
    • type: string
    • If the gist has multiple files, specify the filename you want to show
  • data-gist-line
    • type: string
    • Line numbers you want to show. The rest are removed.
    • Examples:
      • 1,2,3 // Only shows lines 1, 2 and 3
      • 1-4 // Only shows lines 1, 2, 3, and 4
      • 1-4,8 // Only shows lines 1, 2, 3, 4, and 8
  • data-gist-highlight
    • type: string
    • Line numbers you want to highlight. Uses the same syntax for line ranges as data-gist-line

Contributing

Setup

  • I recommend using VSCode to develop
  • Install prettier VSCode extension
  • npm install

Development

  • To start the dev server: npm run dev
  • This starts webpack with a local web server and hot reloading
  • navigate to http://localhost:8080/
  • webpack serves the compiled TypeScript index.ts to /dist/gist-embed.min.js when in development mode

Tests

  • Please add unit tests for your new code.
  • npm test
  • Use Rewire methods to get access to private functions in index.ts. See tests/index.test.js for examples.
  • Add an example to index.html

Committing

  • Update the README with the new jsdelivr script based on new version bump
  • Husky, a git hook tool, will automatically lint and run prettier when you git commit as well as run jest tests and create the prod minified bundle.

FAQ

What happened to blairvanderhoof/gist-embed based on jQuery?

  • My old github account couldn't be recovered, so starting with a new repo here.
  • I always wanted to rewrite gist-embed to not use jQuery and simplify the code.
  • Going forward, this will be where all gist-embed code will reside.

Can I still use blairvanderhoof/gist-embed?

  • That account will probably go away soon. If you really need to rely on it, I suggest forking it before it's removed.

But I like using jQuery!

  • This will be a plain vanilla JS library from now on.
  • The gists should load much faster now that we are removing jQuery as a dependency.

How did you lose your old account?

  • Lesson learned - always keep up to date 2FA recovery codes if you have 2FA enabled on your account and lose your authentication app :(