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

sanity-api

v1.0.3

Published

simple and efficient interface for interacting with the sanity.io API

Downloads

132

Readme

sanity.io

This npm module provides a simple and efficient interface for interacting with the Sanity.io API, a platform for structured content management. In addition, it offers React components for displaying PortableText (Rich text) content.

Features

  • Getting data from Sanity.io: Easily interact with the Sanity.io API.
  • Block Content: Display rich text content from Sanity.io in your React application with the provided PortableText components.

Getting data from Sanity.io

You can customize your query to get the data you need from Sanity.io. You can find more information about the query language here: https://www.sanity.io/docs/how-queries-work. For this integration, we used the following query:

`*[_type == 'product' && store.slug.current == '${slug}'][0]`

For simplicity, the dataset that is configured for this project is public. If you want to use a private dataset, you'll need to add the token to the Authorization header in the api function. You can find more information about this here.

Block Content

Sanity.io is very flexible and can be used for many different purposes. In this integration, we used Sanity.io to add some extra information to our products. This additional information is of a block type. Showing this additional information on the product page is a great way to tell a story about your products and make them more appealing to your customers. For that we created the component PortableText that shows some but not all of the possible features of the block type. You will need to customize the serializer or even add new ones to more features of the block type (Instagram, Images, Call to Action, etc).

Installation

You can install the sanity.io module via npm:

npm install sanity.io

Usage

API Interaction

You can import the API functions from the module like so:

import { getProductFromSlug } from 'sanity.io';

Then, you can use these functions in your application to interact with the Sanity.io API.

PortableText Components

You can import the PortableText component from the module like so:

import { PortableText } from 'sanity.io';

Then, you can use this component in your React application to display rich text content from Sanity.io.

Contributing

Contributions to the sanity.io module are welcome. Please submit a pull request or open an issue for any changes or improvements you would like to suggest.

License

This module is licensed under the MIT License. See the LICENSE file for more information.

Local Development

To work on this project locally, you can follow these steps:

  1. Clone the repository:
git clone https://github.com/tres-caras/sanity.io.git
  1. Install the dependencies:
npm install
  1. Make your changes to the code.

Building

To build the project, run the following command:

npm run build

This will generate a production version of your package in the dist folder.

Publishing

Before publishing a new version of the package, make sure you have built the latest changes:

npm run build

Then, you can publish the package to npm with:

npm publish

Please make sure to follow semantic versioning when publishing new versions.