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

@wearegoat/scheduled-publishing

v1.0.2

Published

Forked scheduled publishing sanity plugin

Downloads

4

Readme

Scheduled Publishing plugin for Sanity.io

This is a fork of the now vendored scheduled publishing plugin. The plugin itself is deployed as a private npm package

What is it?

Schedule your content for future publication and organise upcoming releases – no custom tasks or serverless functions required!

This plugin uses Sanity's Scheduling API which is available to customers on Growth or higher plans.

Scheduled Publishing tool view

Scheduled Publishing document view

Table of contents

Features

Create and edit schedules directly from the document editor

  • Create and edit schedules for the document you're working on
  • See current schedule status and potential validation issues

View all your schedules with our dedicated tool

  • Filter all schedules by status or use the calendar to browse by date
  • Edit, delete, and immediately publish schedules
  • Automatically validate upcoming schedules, and identify issues before they're published
  • Easily identify who created a schedule

View schedule dates in any remote time zone

  • Change the time zone you want to preview schedules in by clicking the 🌎 Time Zone button when visible. Great when you need to co-ordinate with a global team or want to time publication to specific regions.
  • Easily select time zones by city, time zone abbreviation or name search.
  • Selected time zones are automatically stored in your local storage for future use.

Getting started

Installation

npm install --save @sanity/scheduled-publishing

or

yarn add @sanity/scheduled-publishing

Usage

Add it as a plugin in sanity.config.ts (or .js):

import {scheduledPublishing} from '@sanity/scheduled-publishing'

export default defineConfig({
  // ...
  plugins: [scheduledPublishing()],
})

This will automatically:

  • Add a Schedule document action to all document types
  • Display a Scheduled document badge to all document types
  • Add the dedicated Schedules tool in your navigation bar

Please see Custom setup for more fine grained control on limiting schedule buttons to specific document types and working with existing custom document actions or badges.

Custom setup

This plugin also exports both the Schedule document action and Scheduled badge which you can import and compose as you see fit.

Manually configuring the Schedule document action

This example assumes you've customised your own document actions and would like to only show the Schedule button on movie documents only.

The Schedule document action allows users to both create and edit existing schedules directly from the form editor. It is added to all document types by the plugin, so you should remove it from types that should NOT have it.

import {scheduledPublishing, ScheduleAction} from '@sanity/scheduled-publishing'

export default defineConfig({
  // ...
  plugins: [scheduledPublishing()],
  document: {
    actions: (previousActions, {schemaType}) => {
      /*
       * Please note that this will only alter the visibility of the button in the studio.
       * Users with document publish permissions will be able to create schedules directly
       * via the Scheduled Publishing API.
       */
      if (schemaType.name !== 'movie') {
        // Remove the schedule action from any documents that is not 'movie'.
        return previousActions.filter((action) => action !== ScheduleAction)
      }
      return previousActions
    },
  },
})

Manually configuring the Scheduled document badge

This example assumes you've customised your own document badges and would like to only show the Scheduled badge on movie documents only.

The Scheduled document badge displays whether the current document is scheduled and when it will be published if so. It is added to all document types by the plugin, so you should remove it from types that should NOT have it.

import {scheduledPublishing, ScheduledBadge} from '@sanity/scheduled-publishing'

export default defineConfig({
  // ...
  plugins: [scheduledPublishing()],
  document: {
    actions: (previousBadges, {schemaType}) => {
      if (schemaType.name !== 'movie') {
        // Remove the schedule badge from any documents that is not 'movie'.
        return previousBadges.filter((badge) => badge !== ScheduledBadge)
      }
      return previousBadges
    },
  },
})

FAQ

Schedules sit adjacent to your dataset and can be managed using the Scheduling API (which this plugin does for you).

Schedules are a unique resource and are linked to, but do not exist within your Sanity project and dataset. It's important to understand the following behavior:

  • As schedules are not contained within a project’s dataset, you cannot query them via GROQ or GraphQL.
  • Deleting a dataset will immediately delete all schedules.
  • Deleting a project will immediately delete all schedules.
  • sanity dataset export will not include schedules and sanity dataset import does not support importing schedules.
  • Server-side copying of datasets does not include schedules.
  • When a project is disabled or blocked, all scheduled publishes will invariably fail as mutations will not be allowed on the dataset.

More information can be found on the Scheduling API page.

  • Time zones and their corresponding cities, regions and daylight savings offsets are directly sourced from the @vvo/dztb library, which is automatically updated with data from geonames.org.

  • Latest time zone + region data from @vvo/dztb is pulled in when first installing this plugin.

  • In the event you need to bring in upstream time zone and region data, run:

    # Yarn
    yarn upgrade @sanity/scheduled-publishing
    
    # NPM
    npm update @vvo/tzdb --legacy-peer-deps
  • Yes. Documents scheduled to publish in future will do so, even if they contain validation errors. This also applies to scheduled documents that you manually opt to publish immediately via the tool.

Changes from Sanity Studio v2 version

The Studio V3 version differs from the v2 versions in a few ways:

  • Actions and badges now auto-compose with other document actions by default. This is the opposite of how the v2 version behaves: It is no longer necessary to compose actions and badges manually when there are other plugins that add those to studio.
  • This means that you now have to remove the Schedule Action from types that should not have it, as opposed to add it for those that should like in v2.

License

This repository is published under the MIT license.

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

MIT-licensed. See LICENSE.

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.

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.