DEV Community

Vu Minh Thang
Vu Minh Thang

Posted on

11 4

Using Web Monetization with Gridsome

What I built

I built a developer portfolio website. I would like to hide sensitive information (e.g. contact information) from public.

Submission Category: Exciting Experiments

Demo

https://me.coddeine.com/

Link to Code

GitHub logo ittus / vue-developer-profile

Developer's portfolio built with Gridsome + VueJS

Developer profile

Developer profile's built with Gridsome + VueJS

Checkout demo

Gridsome + Vue

Support

Buy Me A Coffee

Develop

  • Fork this repository
  • Run following command
npm install
npm run develop
Enter fullscreen mode Exit fullscreen mode

Build

npm run build
Enter fullscreen mode Exit fullscreen mode

Customize

Most of information is pulled from profile.json file. Please change it to your information.

Portfolio section

Portfolio (or project) data is read from Markdown file in /src/data/projects folder. Feel free to use any Markdown syntax in there.

License

MIT




How I built it

Integrated Web Monetization (Coil) and Gridsome is quite easy.
First I created index.html and in src folder and add Coil meta's tag

<!DOCTYPE html>
<html ${htmlAttrs}>
  <head>
    ${head}
    <meta name="monetization" content="$ilp.uphold.com/fPDnd2Pr32mP">
  </head>
  <body ${bodyAttrs}>
    ${app}
    ${scripts}
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Then I add the code to check if user is a paid user or not

  data: () => ({
    isPaid: false
  }),
  created() {
    if (process.isClient) {
      if (document.monetization) {
        document.monetization.addEventListener('monetizationstart', event => {
          if (document.monetization.state === 'started') {
            this.isPaid = true
          }
        });
      }
    }
  }
Enter fullscreen mode Exit fullscreen mode

and then I can use the isPaid flag in other conditional statement

    downloadResume() {
      if (!this.isPaid) {
         // do something
      } else {
        // do something else
      }
    }
Enter fullscreen mode Exit fullscreen mode

You can see more detail implementation in my Github repository

Additional Resources/Info

Web Monetization is a nice idea for me. I hope it will be adopted soon by other developers and content creators. Using Coil, it's very easy to add it to your website.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
sergix profile image
Peyton McGinnis • Edited

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay