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

@commercelayer/sanity-plugin-commerce

v1.0.0

Published

Create and manage a product catalogue within Sanity

Downloads

74

Readme

Sanity Commerce by Commerce Layer

This is a Sanity Studio v3 plugin.

Rationale

Traditionally, product catalogs and commerce engines are closely tied together, often leading to complex management and limited flexibility in content presentation. This plugin proposes a paradigm shift by decoupling the product catalog from the commerce engine. It enables you to manage your product catalog within Sanity CMS, while platforms like Commerce Layer handle the transactional aspects. This approach offers enhanced content management capabilities, improved editorial workflows, and a richer user experience.

Features

The Sanity Commerce Plugin is designed to seamlessly integrate e-commerce functionalities into Sanity CMS. Focused on simplifying content management for e-commerce platforms, this plugin allows you to manage your product catalog directly within Sanity, leveraging the power and flexibility of headless commerce.

  • Spin up a content model to handle products within Sanity.
  • Customizable schema for products, variants, taxonomies, and taxons.
  • Flexible configuration options to adapt to different e-commerce needs.
  • Streamlined management of product details, variants, and categorizations.

Installation

npm install @commercelayer/sanity-plugin-commerce

Usage

Configure the plugin in your sanity.config.ts file. Here’s an example configuration:

import { defineConfig } from 'sanity';
import {
  sanityCommerce,
  SanityCommercePluginConfig,
} from '@commercelayer/sanity-plugin-commerce';

const sanityCommerceConfig: SanityCommercePluginConfig = {
  // ...configure the plugin here.
};

export default defineConfig({
  // ... other config settings.
  plugins: [sanityCommerce(sanityCommerceConfig)],
});

Configuration Options

For product and variant attributes, there are some fields already preconfigured. Using field names that already exist will override the default content model. It is highly recommended to check the result of the content model before adding custom extensions.

The Sanity Commerce Plugin offers flexible configuration to adapt to your specific e-commerce needs. Below is a table summarizing the configuration options:

| Option | Type | Description | Example | | ------------------- | ------------------- | ---------------------------------------------------------- | -------------------------------------------- | | productLabel | string | Sets the display name for products in the CMS. | 'Coffee' | | variantLabel | string | Sets the display name for product variants. | 'Coffee Variant' | | taxonomyLabel | string | Sets the display name for taxonomies. | 'Category System' | | taxonLabel | string | Sets the display name for individual taxons or categories. | 'Category' | | productAttributes | FieldDefinition[] | An array of additional field definitions for the product. | [ { name: 'origin', type: 'string' } ] | | variantAttributes | FieldDefinition[] | An array of additional field definitions for the variant. | [ { name: 'roastLevel', type: 'string' } ] |

Example Configuration

Here is a full example of how you might configure the plugin in your sanity.config.ts:

import { defineConfig } from 'sanity';
import { sanityCommerce } from 'sanity-plugin-commerce';

const sanityCommerceConfig = {
  productLabel: 'Coffee',
  variantLabel: 'Coffee Variant',
  taxonomyLabel: 'Category System',
  taxonLabel: 'Category',
  productAttributes: [{ name: 'origin', title: 'Origin', type: 'string' }],
  variantAttributes: [
    {
      name: 'roastLevel',
      title: 'Roast Level',
      type: 'string',
      options: {
        list: [
          { title: 'Light', value: 'light' },
          { title: 'Medium', value: 'medium' },
          { title: 'Dark', value: 'dark' },
        ],
      },
    },
  ],
};

export default defineConfig({
  plugins: [sanityCommerce(sanityCommerceConfig)],
});

This configuration allows you to tailor the plugin to best fit your product catalog and editorial workflow.

Develop & test

This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.

See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.

License

This plugin is released under the MIT License © Commerce Layer.

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.