|
13 | 13 | $includeUnlisted = option('splorp.paperback-export.includeUnlisted', true); |
14 | 14 | $includeChildren = option('splorp.paperback-export.includeChildren', []); |
15 | 15 | $excludeTemplate = option('splorp.paperback-export.excludeTemplate', []); |
| 16 | + $includeDatestamp = option('splorp.paperback-export.includeDatestamp', false); |
16 | 17 |
|
17 | 18 | if (! is_string($prefix)) { |
18 | 19 | throw new Exception('The option “splorp.paperback-export.prefix” must be a string.'); |
|
29 | 30 | if (! is_array($excludeTemplate)) { |
30 | 31 | throw new Exception('The option “splorp.paperback-export.excludeTemplate” must be an array.'); |
31 | 32 | } |
| 33 | + if (! is_bool($includeDatestamp)) { |
| 34 | + throw new Exception('The option “splorp.paperback-export.includeDatestamp” must be a boolean.'); |
| 35 | + } |
32 | 36 |
|
33 | 37 | $languages = site()->languages(); |
34 | 38 | $pages = site()->index(); |
35 | 39 | $title = site()->title(); |
36 | 40 | $description = site()->description(); |
37 | 41 | $version = site()->version(); |
38 | | - $datestamp = date('Y-M-d'); |
39 | 42 | $filename = str::slug($title); |
40 | 43 |
|
41 | 44 | /* Check whether to include unlisted pages */ |
|
54 | 57 |
|
55 | 58 | $pages = $pages->filterBy('intendedTemplate', 'not in', $excludeTemplate); |
56 | 59 |
|
| 60 | + /* Check whether to include a datestamp */ |
| 61 | + |
| 62 | + if ($includeDatestamp) { $datestamp = date('Y-M-d'); } else { $datestamp = ''; } |
| 63 | + |
| 64 | + /* Define template and variables */ |
| 65 | + |
57 | 66 | $template = __DIR__ . '/snippets/export.php'; |
58 | 67 | $paperback = tpl::load($template, compact('languages', 'pages', 'title', 'description', 'prefix', 'fields', 'version', 'datestamp', 'filename')); |
59 | 68 |
|
|
0 commit comments