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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xingwangzhe/satteri-photoswipe

v0.1.7

Published

Satteri HAST plugin that wraps images with PhotoSwipe lightbox containers

Readme

@xingwangzhe/satteri-photoswipe

中文文档 | English

Satteri HAST plugin that wraps <img> with PhotoSwipe v5 <a> containers using official attributes.

Features

  • PhotoSwipe v5 native — uses data-pswp-width, data-pswp-height, data-pswp-srcset, data-cropped
  • Auto attribute mappingwidth/heightdata-pswp-*, altaria-label, srcsetdata-pswp-srcset
  • Class-based selectora.pswp-gallery-item works with Markdown images (no dimensions needed at build time)
  • Tree-shakeable defaultSelector — a plain string constant, importing it won't pull HAST plugin code into your client bundle
  • Zero-configphotoswipe() just works

Install

bun add @xingwangzhe/satteri-photoswipe

Requires satteri >= 0.8.0. PhotoSwipe v5 must be loaded client-side.

Usage

Build-time: HAST plugin

// astro.config.mjs
import { photoswipe } from "@xingwangzhe/satteri-photoswipe";

export default defineConfig({
  markdown: {
    processor: satteri({
      hastPlugins: [photoswipe()],
    }),
  },
});

Markdown image:

![A photo](photo.jpg)

Output:

<a
  href="photo.jpg"
  class="pswp-gallery-item"
  data-pswp-width="800"
  data-pswp-height="600"
  aria-label="A photo"
>
  <img src="photo.jpg" alt="A photo" />
</a>

Client-side: PhotoSwipeLightbox

defaultSelector is a pure string constant ("a.pswp-gallery-item"). Importing it only brings ~1 KB of JS into your client bundle — no HAST/satteri dependency.

import PhotoSwipeLightbox from "photoswipe/lightbox";
import PhotoSwipe from "photoswipe";
import { defaultSelector } from "@xingwangzhe/satteri-photoswipe";

const lightbox = new PhotoSwipeLightbox({
  gallery: "[data-pagefind-body]", // your article container
  children: defaultSelector, // "a.pswp-gallery-item"
  pswpModule: PhotoSwipe,
});
lightbox.init();

Note: defaultSelector is safe to import in browser code. It's a plain string constant that tree-shakes cleanly — unlike the photoswipe() and createPhotoswipePlugin() functions, which are HAST plugin factories intended only for build-time use.

API

photoswipe(options?)

| Option | Type | Default | Description | | ----------- | --------- | ----------------------- | ------------------------------------------------ | | className | string | "pswp-gallery-item" | CSS class added to each wrapped <a> | | selector | string | "a.pswp-gallery-item" | Gallery selector for PhotoSwipeLightbox | | cropped | boolean | false | Add data-cropped="true" for cropped thumbnails |

defaultSelector

A plain string constant: "a.pswp-gallery-item". Pass directly to PhotoSwipeLightbox({ children: defaultSelector }).

Tree-shakeable — imports only the string itself, no HAST plugin code.

createPhotoswipePlugin(options?)

Build-time only. Returns { plugin, selector }. For advanced use cases.

How it maps attributes

| <img> attribute | <a> attribute | PhotoSwipe v5 usage | | ----------------- | ------------------ | ----------------------------- | | src | href | Full-size image URL | | width | data-pswp-width | Image width in px (required) | | height | data-pswp-height | Image height in px (required) | | srcset | data-pswp-srcset | Responsive images | | data-pswp-src | data-pswp-src | Passthrough (overrides href) | | alt | aria-label | Accessibility |

License

MIT