mauricerenck / autopublish
Set a date to automatically publish a page
Package info
github.com/mauricerenck/autopublish
Type:kirby-plugin
pkg:composer/mauricerenck/autopublish
Requires
- php: >=8.2.0
- getkirby/composer-installer: ^1.2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This Kirby plugin will auto publish selected pages. Enable auto publishing for certain pages in the panel and set a date when to publish the page. Autopublish will handle the rest.
Installation
Use one of these methods to install the plugin:
- composer (recommended):
composer require mauricerenck/autopublish - zip file: unzip main.zip as folder
site/plugins/autopublish
Usage
Add panel fields
Add the autopublish field to your page blueprint:
fields: autopublish: fields/autopublish
Or add the toggle and date field by yourself:
fields: autopublish: label: Autopublish type: toggle translate: false autopublishDate: label: Autopublish Date type: date time: true translate: false when: autopublish: true
If you already have a date field you want to use, you can configure the plugin to use it, by setting this option in your config.php
'mauricerenck.autopublish.dateField' => 'my-date-field',
Configure and use the webhook
First set a secret in your config.php:
'mauricerenck.autopublish.secret' => 'my-secret',
You can now trigger the Webhook:
https://example.com/autopublish/cron/my-secret
Replace example.com with your hostname and my-secret with the secret you set in your config.php. Whenever you trigger the Webhook the plugin will look for unpublished pages with a date older or equal to the current date-time and then publishes the page.
Publish on page load
If you don't have a cron job available, you can instead have the plugin check for due pages on every frontend page load, before the page is rendered:
'mauricerenck.autopublish.onPageLoad' => true,
The drafts scan runs at most once per onPageLoadInterval seconds (default 60). Kirby's cache stores the time of the last run, so most requests in between skip the scan entirely:
'mauricerenck.autopublish.onPageLoadInterval' => 60,
Only one trigger is active at a time: when onPageLoad is enabled, the webhook is disabled and always responds with Forbidden.
Options
Please make sure to prefix all options with mauricerenck.autopublish or use the array notation.
| Option | Default | Description |
|---|---|---|
dateField |
'autopublishDate' |
The field name of your date field |
secret |
'' |
A secret to secure the webhook |
onPageLoad |
false |
Also check for due pages on every page render |
onPageLoadInterval |
60 |
Minimum seconds between checks when onPageLoad is on |
