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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lodashventure/medusa-product-content

v1.3.26

Published

Medusa Admin plugin for enhanced product content management with rich text editor and i18n specifications

Readme

Medusa Product Content Plugin

Enhanced product content management with rich text editor and i18n specifications for Medusa Admin.

Features

  • Rich Text Editor: TipTap-based editor for long product descriptions
  • i18n Specifications: Multilingual key-value product specifications
  • Version History: Automatic versioning of content changes
  • Import/Export: CSV/JSON import and export for specifications
  • SEO-Friendly: HTML sanitization and auto-excerpt generation
  • Drag & Drop: Reorder specification groups and items
  • Locale Support: Full internationalization support

Installation

npm install @medusajs/admin-product-content
# or
yarn add @medusajs/admin-product-content

Configuration

Add the plugin to your medusa-config.js:

module.exports = {
  // ... other config
  plugins: [
    {
      resolve: '@medusajs/admin-product-content',
      options: {
        locales: [
          { code: 'th-TH', label: 'ไทย', isDefault: true },
          { code: 'en-US', label: 'English' }
        ],
        defaultLocale: 'th-TH',
        versioning: {
          enabled: true,
          maxVersions: 10
        }
      }
    }
  ]
}

Usage

Admin Interface

  1. Navigate to any product in Medusa Admin
  2. Find the "Product Content" widget on the product detail page
  3. Click "Manage Content" to open the content editor
  4. Use the tabs to manage:
    • Overview: View product information and content status
    • Long Description: Edit rich text content
    • Specifications: Manage i18n product specs
    • Versions: View and restore content history

Storefront Integration

Fetch product content via the Store API:

// Fetch product with metadata
const product = await fetch('/store/products/prod_123?expand=metadata')
  .then(res => res.json())

// Access long description
const longDescription = product.metadata?.long_description

// Access specifications
const specs = product.metadata?.specs

// Helper function for locale fallback
function getSpecValue(item, locale, fallbackLocale) {
  return item.i18n[locale]?.value ||
         item.i18n[fallbackLocale]?.value ||
         ''
}

Data Structure

Long Description

{
  "metadata": {
    "long_description": {
      "html": "<h1>Product Title</h1><p>...</p>",
      "richjson": { /* TipTap JSON */ },
      "locale": "th-TH",
      "updated_at": "2025-01-01T00:00:00Z",
      "updated_by": "[email protected]"
    }
  }
}

Specifications

{
  "metadata": {
    "specs": {
      "default_locale": "th-TH",
      "groups": [
        {
          "key": "electrical",
          "position": 1,
          "i18n": {
            "th-TH": { "label": "ข้อมูลไฟฟ้า" },
            "en-US": { "label": "Electrical" }
          },
          "items": [
            {
              "position": 1,
              "i18n": {
                "th-TH": { "key": "กำลังไฟ", "value": "18 วัตต์" },
                "en-US": { "key": "Power", "value": "18 W" }
              },
              "visible": true
            }
          ]
        }
      ]
    }
  }
}

Import/Export

CSV Format

group_key,group_position,group_label.th-TH,group_label.en-US,item_position,key.th-TH,value.th-TH,key.en-US,value.en-US,visible
electrical,1,ข้อมูลไฟฟ้า,Electrical,1,กำลังไฟ,18 วัตต์,Power,18 W,true
electrical,1,ข้อมูลไฟฟ้า,Electrical,2,ความสว่าง,1800 ลูเมน,Brightness,1800 lm,true

JSON Format

Export and import full specification structure as JSON for complete data preservation.

API

Hooks

import { useProductContent } from '@medusajs/admin-product-content'

const {
  product,
  longDescription,
  specs,
  versions,
  updateLongDescription,
  updateSpecs,
  restoreVersion
} = useProductContent({ productId: 'prod_123' })

Utilities

import {
  sanitizeHTML,
  generateExcerpt,
  localeUtils,
  getLocalizedSpec
} from '@medusajs/admin-product-content'

// Sanitize HTML
const clean = sanitizeHTML(dirtyHtml)

// Generate excerpt
const excerpt = generateExcerpt(html, 160)

// Get localized value
const value = getLocalizedSpec(item, 'en-US', 'th-TH', 'value')

// Calculate completeness
const completeness = localeUtils.calculateLocaleCompleteness(specs, 'en-US')

Security

  • All HTML content is sanitized using DOMPurify
  • Scripts and dangerous attributes are removed
  • Only admin users with product:update permission can edit content

License

MIT

Support

For issues and feature requests, please visit the GitHub repository.