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

docusaurus-plugin-native-ideal-image

v0.1.2

Published

Pre-process images to multiple formats and low quality image placeholders

Downloads

9

Readme

Docusaurus Native Ideal Image Plugin

A docuaurus plugin for pre-processing images to multiple formats, sizes and low quality image placeholders, replacing ideal-image

Note: this is still working in progress

Usage

First install

npm install docusaurus-plugin-native-ideal-image

And add the configuration to docusaurus.config.js/docusaurus.config.ts

const config = {
    ...
    plugins: ['native-ideal-image'],
}

Then you can use it in your project like this

import image from 'ideal-img!../images/some-image.jpeg'

<NativeIdealImage img={image} />

// or with require
<NativeIdealImage img={require('ideal-img!../images/some-image.jpeg')} />

To use it for markdown images by default, add this to the configuration

import { nativeIdealImageRemarkPlugin } from 'docusaurus-plugin-native-ideal-image'

const config = {
    presets: [
        [
            'classic',
            {
                // The same for docs and blog
                pages: {
                    remarkPlugins: [nativeIdealImageRemarkPlugin],
                },
                ...
            },
        ],
    ],
}

By default, this will transform the image into a jpeg source and a webp source and also a webp format low quality placeholder, and end up like this

<picture
    class="native-ideal-img"
    style="--lqip: url(data:image/webp;base64,UklGRj4AAABXRUJQVlA4IDIAAADQAQCdASoQAAwABUB8JZQAAudcoVPyIAD+uVyF4iJZsGTWpdieB7utExa6oMeh0PusAA==);"
>
    <source srcset="assets/native-ideal-image/some-image-b0600-2160.webp" type="image/webp" />
    <img loading="lazy" src="assets/native-ideal-image/some-image-6ee75-2160.jpeg" width="2160" height="1620" />
</picture>

You can use query strings to change the output, currently you can do

  • w: changes the output sizes
  • formats: changes the formats used
  • presets: use a preset set in the config

Example: import image from 'ideal-img!../images/some-image.jpeg?w=800,1200&formats=avif,webp'

You can learn more in the example directory or see some live examples in https://legend-master.github.io/docusaurus-plugin-native-ideal-image

TypeScript

To use with TypeScript, put "docusaurus-plugin-native-ideal-image/types" in compilerOptions > types in your tsconfig.json or put /// <reference type="docusaurus-plugin-native-ideal-image/types" in a .d.ts file to get @theme/NativeIdealImage and ideal-img!* type