Skip to content

Commit

Permalink
Add new option to override date display.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottboms committed Feb 10, 2024
1 parent 5b6bce1 commit 2bc8008
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ In any template, drop in the following line to include the output from this plug
If you want to modify the wrapper HTML element, change the wrapper class, or output the date information in a custom format, you can configure this using the included plugin options. Date formatting follows the [available format options from PHP](https://www.php.net/manual/en/function.date.php).

'scottboms.microseasons' => [
'wrapper' => 'div',
'wrapper' => 'div', // e.g. div, article, section, span, etc.
'class' => 'microseasons',
'dateformat' => 'M d, Y'
'includedates' => True, // True | False
'dateformat' => 'M d, Y' // e.g. 'M d', 'Y-m-d', etc.
],

## Disclaimer
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "scottboms/microseasons",
"description": "Kirby Micro Seasons plugin",
"type": "kirby-plugin",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/scottboms/kirby-microseasons",
"authors": [
{
Expand All @@ -14,9 +14,9 @@
"license": "MIT",

"keywords": [
"kirby3",
"kirby3-cms",
"kirby3-plugin"
"kirby",
"kirby-cms",
"kirby-plugin"
],
"require": {
"getkirby/composer-installer": "^1.1"
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Kirby Japanese Microseasons Plugin
*
* @version 1.0.0
* @version 1.0.1
* @author Scott Boms <[email protected]>
* @copyright Scott Boms <[email protected]>
* @link https://github.com/scottboms/kirby-microseasons
Expand All @@ -23,6 +23,7 @@
'options' => [
'wrapper' => 'div',
'class' => 'microseasons',
'includedates' => True,
'dateformat' => 'M d'
],
'snippets' => [
Expand Down
8 changes: 5 additions & 3 deletions snippets/microseasons.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
<?= $matchSeason['translation'] ?>
<?= $matchSeason['name'] ?>
</span>
<time class="ms__range" datetime="<?= $matchSeason['start'] ?>/<?= $matchSeason['end']?>">
<?= $matchSeason['start']->format(option('scottboms.microseasons.dateformat', 'M/d')) ?> to <?= $matchSeason['end']->format(option('scottboms.microseasons.dateformat', 'M/d')) ?>
</time>
<?php if(option('scottboms.microseasons.includedates') === True): ?>
<time class="ms__range" datetime="<?= $matchSeason['start'] ?>/<?= $matchSeason['end']?>">
<?= $matchSeason['start']->format(option('scottboms.microseasons.dateformat', 'M/d')) ?> to <?= $matchSeason['end']->format(option('scottboms.microseasons.dateformat', 'M/d')) ?></time>
<?php else: ?>
<?php endif ?>
</dd>
</dl>
</div>

0 comments on commit 2bc8008

Please sign in to comment.