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

gatsby-theme-web-monetization

v0.0.2

Published

A theme for integrating the Web Monetization API on your Gatsby site

Downloads

6

Readme

Features

  • 💸 Accept payment stream via the Web Monetization API on your website/app
  • 💙 Display monetization status, call to action banner, and show exclusive content to users with Web Monetization
  • 😎 No imports required! (for MDX content)

Web Monetization?

Web Monetization provides an open, native, efficient, and automatic way to compensate creators, pay for API calls, and support crucial web infrastructure.

Web Monetization is ”a JavaScript browser API which allows the creation of a payment stream from the user agent to the website”. Learn more about the API and about Interledger as the transfer protocol on webmonetization.org.

Installation

New site

# create a new site at the directory "my-monetized-site"
gatsby new my-monetized-site https://github.com/ekafyi/starter-web-monetized-theme

Go to your site directory, open gatsby-config.js, and modify the paymentPointer option with your own wallet’s payment pointer.

Existing site

  1. Install the theme
npm install gatsby-theme-web-monetization
# or yarn add gatsby-theme-web-monetization
  1. Add the configuration to your gatsby-config.js file
// gatsby-config.js
module.exports = {
  // ... other stuff
  plugins: [
    // ... other plugins
    {
      resolve: `gatsby-theme-web-monetization`,
      options: {
        paymentPointer: "$wallet.example.com/eka" // Your wallet's payment pointer
      },
    },
  ]
}

Usage

⚠️ Important ⚠️ To accept payment, you have to set up a web monetized wallet and get your payment pointer (steps 1-2 in the Quick Start Guide).

Theme Options

This theme only has one (optional) option, paymentPointer. Your payment pointer should be in this format: $wallet.example.com/eka.

If you skip this option, you have to add the monetization metadata yourself as shown in Steps 3 - 4 in this guide. You should do this if, for instance, you’d like to enable monetization only in some parts of your site.

Components

As long as your metadata has a valid payment pointer, you don’t need any particular component to receive payments. That said, this theme provides these handy UI components to give you a quick start in telling your users about your new web monetized site 😌.

WebMonetizedStatus

Display content based on user’s Web Monetization status. Usage and props

<WebMonetizedStatus
  active='Yay! Web Monetization is active!'
  inactive='Web Monetization is inactive'
/>

WebMonetizedPaywall

Display “paywall” content (eg. description and call-to-action) users without active Web Monetization. Usage and props

<WebMonetizedPaywall 
  title="Sorry, you cannot see this content"
  body="Want to know the answer to the ultimate question of life, the universe, and everything? Enable Web Monetization now."
/>

IfWebMonetized

The opposite of WebMonetizedPaywall—display content to users with active Web Monetization.

<IfWebMonetized>
  The answer to the ultimate question of life, the universe, and everything is <strong>42</strong>.
</IfWebMonetized>

This component comes from react-web-monetization, which this theme uses as dependency. As such, all components from the library is available for you to import without you having to install the package on your site.

Using in MDX

This theme wraps your site with an MDXProvider, so you should be able to use all the components right away in your MDX pages—no imports needed.

---
title: Example Post
date: 2020-06-03
---

Hello world! Why did the chicken cross the road?

<WebMonetizedPaywall />

<IfWebMonetized>
  To get to the other side.
</IfWebMonetized>

Importing components

You can import the components to use elsewhere outside MDX, or for creating customized components to pass to your own MDXProvider.

// my-component.js
import React from "react";
import { WebMonetizedStatus, WebMonetizedPaywall, MdxWebMonetizationProvider } from "gatsby-theme-web-monetization";
import { IfWebMonetized, useMonetizationCounter } from "react-web-monetization"; // You can import anything from https://github.com/sharafian/react-web-monetization

This theme has been tested to work with another theme that also wraps the site with an MDXProvider, gatsby-mdx-embed; but in case the Provider does not work, you can import MdxWebMonetizationProvider and wrap your MDXRenderer in your own layout component manually.

Examples

Coming soon