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

@sklinet/strapi-plugin-publisher

v1.0.0

Published

A plugin for Strapi Headless CMS that provides the ability to schedule publishing for any content type.

Downloads

64

Readme

strapi-plugin-publisher

A plugin for Strapi that provides the ability to easily schedule publishing and unpublishing of any content type.

Requirements

The installation requirements are the same as Strapi itself and can be found in the documentation on the Quick Start page in the Prerequisites info card.

Supported Strapi versions

  • v5.x.x

NOTE: While this plugin may work with the older Strapi versions, they are not supported, it is always recommended to use the latest version of Strapi.

Installation

npm install @SKLINET/strapi-plugin-publisher

Configuration

Enable the plugin

The plugin configuration is stored in a config file located at ./config/plugins.js. If this file doesn't exists, you will need to create it.

A sample configuration

module.exports = ({ env }) => ({
  // ..
	'publisher': {
		enabled: true,
		config: {
			hooks: {
				beforePublish: async ({ strapi, uid, entity }) => {
					console.log('beforePublish');
				},
				afterPublish: async ({ strapi, uid, entity }) => {
					console.log('afterPublish');
				},
				beforeUnpublish: async ({ strapi, uid, entity }) => {
					console.log('beforeUnpublish');
				},
				afterUnpublish: async ({ strapi, uid, entity }) => {
					console.log('afterUnpublish');
				},
			},
		},
	},
	// ..
});

The Complete Plugin Configuration Object

| Property | Description | Type | Default | Required | |----------------------------------|----------------------------------------------------------------------------------|----------| ------- | -------- | | actions | Settings associated with any actions. | Object | {} | No | | actions.syncFrequency | The frequency to check for actions to run. It is a cron expression | String | '*/1 * * * *' | No | | components | Settings associated with any of the plugins components | Object | {} | No | | components.dateTimePicker | Settings associated with the DateTimePicker component used to set action times | Object | {} | No | | components.dateTimePicker.step | The step between the numbers displayed for the time section of the DateTimePicker | Number | 1 | No | | components.dateTimePicker.locale | Allows to enforce another locale to change the date layout | String | browser locale | No | | hooks.beforePublish | An async function that runs before a content type is published | Function | () => {} | No | | hooks.afterPublish | An async function that runs after a content type is published | Function | () => {} | No | | hooks.beforeUnpublish | An async function that runs before a content type is un-published | Function | () => {} | No | | hooks.afterUnpublish | An async function that runs after a content type is un-published | Function | () => {} | No | | contentTypes | A list of content type uids where the publish actions should be displayed | Array | All content types | No |

Enable server cron

The cron.enabled configuration option needs to be set to true in Server Configuration for the plugin to work.

Usage

Once the plugin has been installed, configured and enabled a Publisher section will be added to the informations section of the edit view for all content types (single + collection) that have draftAndPublish enabled. The Publisher section will provide the ability to schedule publishing and unpublishing of the content type. The content type publication status is checked every minute.

If the Publisher section does not appear in the admin after the plugin is enabled then a clean rebuild of the admin is required. This can be done by deleting the generated .cache and build folders and then re-running the develop command.

Single Content Type

Sample single content type publisher section

Collection Content Type

Sample collection content type publisher section

Adding a (un)publish date

Navigate to the entity record that should be (un)published, under the informations section click the Add a (un)publish date button. Enter in the date and click save, the entity record will then be (un)published at the specified time.

default

Add a (un)publish date

Editing a (un)publish date

Navigate to the entity record that requires its date changed, under the informations section click the Edit (un)publish date button. Enter in the new date and click save.

Edit a (un)publish date

Deleting a (un)publish date

Navigate to the entity record that contains the date that should be removed, under the informations section click the Delete (un)publish date button.

Delete a (un)publish date