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

astro-webfinger

v2.0.0

Published

This [Astro integration](https://docs.astro.build/en/guides/integrations-guide/) allows any Mastodon instance to discover your Mastodon profile directly from your own domain.

Downloads

25

Readme

astro-webfinger

This Astro integration allows any Mastodon instance to discover your Mastodon profile directly from your own domain.

Try it out In your favorite Mastodon instance, search for @[email protected] and you'll find my Mastodon profile.

Why?

Hosting a live Mastodon site on your own domain is no easy task. If you aren't ready to take that leap you can use your own domain as an alias to point to your Mastodon profile.

This uses the WebFinger protocol to attach information to an email, in this case to point an email address on your own domain to your Mastodon profile.

For example, I have a Mastodon profile at @[email protected]. The astro-webfinger integration is added to my Astro site at https://tonysull.co, allowing any Mastodon instance to discover my account by searching for [email protected].

Installation

# npm
npm i @astrojs/rss
# yarn
yarn add @astrojs/rss
# pnpm
pnpm i @astrojs/rss

Configuration

To configure this integration, pass a config object to the webfinger() function call in astro.config.mjs - both static (SSG) builds an server-rendered (SSR) builds.

Static builds (SSG)

The Webfinger protocol actually depends on using query parameters when searching for accounts. Because query parameters aren't actually supported in static builds, only one account can be provided to the account.

:caution: Query parameters won't actually be used at all when your account is requested, your account information will always be returned for any Webfinger request regardless of what was being searched for.

import webfinger from 'astro-webfinger'

export default defineConfig({
  integrations: [
    webfinger({
      instance: 'myinstance.social',
      username: 'myusername',
    }),
  ],
})

Server-rendering (SSR)

With server-rendering the Webfinger query parameters can be used to actually match accounts. If the same integration options as above are passed during an SSR build, it will function the same as SSG and always return your account regardless of what was searched for.

To take full advantage of the benefits of SSR, the integration can be given an object mapping local usernames on your own domain to the related Webfinger accounts.

import webfinger from 'astro-webfinger'

export default defineConfig({
  site: 'https://tonysull.co',
  integrations: [
    webfinger({
      tony: {
        instance: 'myinstance.social',
        username: 'tony',
      },
      nottony: {
        instance: 'secret.social',
        username: 'someoneelse',
      },
    }),
  ],
})

In the example above, a search for:

What's next?

Fine-grained control of the Webfinger redirect

Currently the list of aliases and links in the Webfinger redirect are hard-coded for basic support. I'm definitely not a power user when it comes to the Fediverse but could see there being good reason to support custom aliases and links!

Have something else in mind? Start a discussion thread open an issue, or file a pull request if you're able to contribute code!

Credits

Inspired by Jekyll::MastodonWebfinger

Related articles

Maarten Balliauw's blog post Mastodon on your own domain without hosting a server

Lindsay Wardell's blog post Integrate Mastodon with Astro