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

@flatbread/resolver-svimg

v1.2.0

Published

Flatbread field resolver that turns an image path into svimg attributes: responsive srcsets, WebP and AVIF variants, and a blurred placeholder.

Readme

@flatbread/resolver-svimg 🖼️

Optimize images for specific fields in content

💾 Install

Use pnpm, npm, or yarn:

pnpm i @flatbread/resolver-svimg

👩‍🍳 Usage

update your flatbread.config.js to optimize images referenced in your content.

// flatbread.config.js
import defineConfig from '@flatbread/config';
import transformer from '@flatbread/transformer-markdown';
import filesystem from '@flatbread/source-filesystem';
import { createSvImgField } from '@flatbread/resolver-svimg';

const transformerConfig = {
  markdown: {
    gfm: true,
    externalLinks: true,
  },
};

export default defineConfig({
  source: filesystem({ extensions: ['.md', '.mdx', '.markdown'] }),
  transformer: transformer(transformerConfig),
  content: [
    {
      path: 'content/posts',
      collection: 'Post',
      refs: {
        authors: 'Author',
      },
    },
    {
      path: 'content/authors',
      collection: 'Author',
      refs: {
        friend: 'Author',
      },
      overrides: [
        createSvImgField('image', { // the field in your content that references your image
          inputDir: 'static/authorImages', // the base directory of your source images
          outputDir: 'static/g', // where to store your optimized images (these should be committed)
          publicPath: '/g', //the base path to add onto the urls in the query data
        }),
        })
      ]
    },
  ],
});

🧰 Options

Since we use rely on svimg for processing images we expose all of their config located here https://github.com/xiphux/svimg#preprocessor-options

for a better experience, here is a copy pasta of the relevent section of their readme

| Option | Default | | | ------------ | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | inputDir | required | The static asset directory where image urls are retrieved from | | outputDir | required | The output directory where resized image files should be written to. This should usually be a subdirectory within the normal static asset directory | | srcGenerator | | An optional function to override the logic of how src URLs are generated for the srcset. This is called once per generated image file, and can be used to customize the generated image URLs - for example, to add or remove path components or to specify a CDN domain.The expected callback signature is:(path: string, { src, inputDir, outputDir }?: SrcGeneratorInfo) => stringThe first parameter is the path to the generated image relative to the outputDir, with path separators already normalized to /. The second optional parameter provides the original image src and the inputDir/outputDir options, and the return value is the URL for the image to be used in the srcset.The default behavior without this parameter will work for common use cases, where the outputDir is a subdirectory of the inputDir static asset directory and the site is served from the root of the domain. | | publicPath | The outputDir relative to the inputDir static asset directory | DEPRECATED publicPath is deprecated and will be removed in the next major version. Use a srcGenerator function instead: (path) => '/my/public/path' + pathThe public path that images will be served from. This will be prepended to the src url during preprocessing. | | avif | true | Whether to generate AVIF versions of images in addition to the original image formats | | webp | true | Whether to generate WebP versions of images in addition to the original image formats |

Querying the data

When overriding a field, your image will be processed and the resulting type will be converted into an SvImg type, querying all of the fields would like this this in gql

image {
  srcset
  srcsetwebp
  srcsetavif
  placeholder
  aspectratio
}

we recommend querying all of the fields, and taking advantage of the fantastic web component exposed by svimg to handle these props -- again, we will copy pasta the relevant docs

when using this component in an framework that supports SSR, s-image needs to be imported client side only

In sveltekit this can be achieved with

if (browser) { import('svimg/dist/s-image'); }
<script>
  import 'svimg/dist/s-image';
</script>

<s-image
  srcset="images/splash-600.jpg 600w, images/splash-1200.jpg 1200w"
  srcsetavif="images/splash-600.avif 600w, images/splash-1200.avif 1200w"
  srcsetwebp="images/splash-600.webp 600w, images/splash-1200.webp 1200w"
/>

Configuration

Component Attributes

| Property | Default | | | --------- | --------------- | ------------------------------------------------------------------------------------------------------------------ | | src | required | Image url | | alt | | Alternate text for the image | | class | | CSS classes to apply to image | | width | | Resize image to specified width in pixels. If not specified, generates images of widths 480, 1024, 1920, and 2560. | | immediate | false | Set to true to disable lazy-loading | | blur | 40 | Amount of blur to apply to placeholder | | quality | sharp default | Quality of the resized images, defaults to sharp's default quality for each image format |

Things of note

The configuration provided in flatbread.config.js will affect what fields are populated when querying the related fields. Based on that provided configuration, specific fields will always return null, for example:

| configuration field | default | note | | ------------------- | ------- | ---------------------------------------------------- | | skipPlaceholder | false | setting to true placerholder will always be null | | srcsetavif | true | setting to false srcsetavif will always be null | | srcsetwebp | true | setting to false srcsetwebp will always be null |