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

medusa-plugin-sanity

v2.0.0

Published

Sanity CMS plugin for Medusa

Downloads

38

Readme

Sanity CMS

Manage the content of your storefront with Sanity CMS.

From v1 to v2

I've changed the plugin to use internationalizedArrayString instead of localeString and localeBlock for any fields using that format. This means that you will have to migrate your existing data to the new format if you want to use v2.

Features

  • Handle the presentational content of your commerce application using Sanity.
  • One-way sync from Medusa to Sanity, allowing you to add additional content through Sanity
  • Benefit from Sanity's advanced CMS features such as localization.

Prerequisites


Sanity File Plugin

This plugin assumes that the Sanity File Plugin is also being used, as it relies on this functionality for storing images.


How to Install

1. Copy the schemas from data/schemas to your Sanity project. (You can add to these schemas to suit your needs.)

2. Run the following command to install the plugin on your Medusa backend:

yarn add medusa-plugin-sanity

3. Set the following environment variables in .env:

  SANITY_PROJECT_ID=<YOUR_SANITY_PROJECT_ID>
  SANITY_DATASET=<YOUR_SANITY_DATASET>
  SANITY_TOKEN=<YOUR_SANITY_TOKEN>

3. In medusa-config.js, :

plugins = [
	//...
	{
		resolve: `medusa-plugin-sanity`,
		options: {
			projectId: process.env.SANITY_PROJECT_ID,
			dataset: process.env.SANITY_DATASET,
			token: process.env.SANITY_TOKEN,
			apiVersion: '2021-10-21',
			useCdn: false, // `false` if you want to ensure fresh data
		},
	},
]

Localization

This plugin assumes that you are using Sanity's field-level localization. The Sanity schema that comes with the plugin is already set up to support this. The schema assumes enligsh as the default language, and this is the field that is synced with Medusa.


Synchronization

The plugin will sync the following fields from Medusa to Sanity on creation/update:

  • title
  • subtitle
  • description
  • handle
  • type
  • tags
  • collection
  • thumbnail
  • images
  • variants
  • options

The plugin will sync the following fields from Sanity to Medusa on update:

  • title
  • subtitle
  • handle
  • thumbnail

Deleting a product in Medusa will also delete the corresponding document in Sanity, but not the other way around.


TODO

  • [ ] Add support for automatically creating types in Sanity
  • [ ] Add check for Sanity File Plugin
  • [ ] Add check for correct types in Sanity
  • [ ] Add support for migrating existing medusa product to Sanity