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

@attributech/nuxt-drupal-image

v0.4.0

Published

Nuxt module for handling Drupal image styles

Readme

@attributech/nuxt-drupal-image

A Nuxt module for handling Drupal image styles.

Features

  • Compatible with Nuxt 2 (with Bridge) and Nuxt 3
  • TypeScript support
  • Auto-imports for the useImageUrl composable
  • Simplifies working with Drupal image styles

Installation

npm install @attributech/nuxt-drupal-image

Setup

Add the module to your nuxt.config.ts:

Nuxt 3

export default defineNuxtConfig({
  modules: [
    '@attributech/nuxt-drupal-image'
  ]
})

Nuxt 2 with Bridge

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  buildModules: [
    '@attributech/nuxt-drupal-image'
  ]
})

Usage

useImageUrl

A composable for building Drupal image style URLs.

const imageUrl = useImageUrl(imageUri, style)

Parameters

  • imageUri: The Drupal image URI (e.g., 'public://image.jpg')
  • style: The Drupal image style name (e.g., 'thumbnail', 'large')

Returns

  • A string containing the complete URL to the styled image

Example

<template>
  <img :src="imageUrl" alt="My image" />
</template>

<script setup>
const imageUri = 'public://my-image.jpg'
const imageUrl = useImageUrl(imageUri, 'large')
</script>

Configuration

The composable uses the serverUrl from your Nuxt runtime config. Make sure to set this in your nuxt.config.ts:

// Nuxt 3
export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      serverUrl: process.env.SERVER_URL || 'https://example.com'
    }
  }
})

// Nuxt 2 with Bridge
export default defineNuxtConfig({
  publicRuntimeConfig: {
    serverUrl: process.env.SERVER_URL || 'https://example.com'
  }
})

Migration from existing code

Migrating from util/imageUrl.js

If you're currently using the utility function from util/imageUrl.js, you can migrate to the composable as follows:

Before:

import imageUrl from '@/util/imageUrl'

const url = imageUrl(imageUri, style, apiUrl)

After:

import { useImageUrl } from '@attributech/nuxt-drupal-image'

// The apiUrl is now taken from the Nuxt runtime config
const url = useImageUrl(imageUri, style)

Development and Testing

Playground

This module includes a playground for testing and development. The playground is a Nuxt 3 application that demonstrates various use cases of the module.

To run the playground:

# Install dependencies
npm install

# Run the playground
npm run dev

This will start a development server at http://localhost:3000 with examples of the module in action.

The playground includes:

  • Basic examples of the DrupalImage component
  • Advanced usage examples with custom image styles
  • Responsive image examples
  • Mock API for simulating Drupal image data

For more details, see the playground README.

Testing

This module includes both unit tests and end-to-end (e2e) tests to ensure functionality works as expected.

Unit Tests

Unit tests are implemented using Vitest and test the core functionality of the module:

# Run unit tests
npm run test:unit

# Run unit tests in watch mode
npm run test:unit:watch

End-to-End Tests

E2E tests use Playwright to test the module in a real Nuxt application context:

# Run e2e tests
npm run test:e2e

# Run e2e tests with UI
npm run test:e2e:ui

Run All Tests

To run both unit and e2e tests:

npm run test:all

License

MIT