Closed ShallowRed closed 2 years ago
@ShallowRed thank you for this useful extension :raised_hands:
Just three very minor things (I could also do these after merging if you don't have time):
Your code is currently indented with tabs and ours uses spaces - would be great to align. Also, in composer.json
you could bump the version. Since you're introducing a new feature, this could be 1.4.0
. And lastly if you want you can already add a small note about the feature in the readme so that others know it exists :) Thank you!
By the way, using a custom page model you could also achieve removing the parent page slug from the URL (e.g. by overriding the url
method).
Anyway, this is a great and useful enhancement, again thanks a lot! :)
Cool, i'll Be back soon with a cleaner PR !
Also, in my fork of the plugin, I have added the possibility to generate files ending with .xml (in order to generate my sitemap.xml)
// static-site-generator/class.php l.322
protected function _cleanPath(string $path): string
{
$path = str_replace('//', '/', $path);
$path = preg_replace('/([^\/]+\.(htm(l)?)|(xml))\/index.html$/i', '$1', $path); // <= here I added '|(xml)' in regex
if (strpos($path, '//') !== false) {
return $this->_cleanPath($path);
}
return $path;
}
Do you think that could be a feature ?
Also, in my fork of the plugin, I have added the possibility to generate files ending with .xml (in order to generate my sitemap.xml)
Good idea, didn't think of other non-binary (or even binary) files one might want to generate that way. I think I'll create a separate PR for this, but make it more generic so it works for any file ending. Thanks for the idea :raised_hands:
Description
Add a configuration option 'custom_filters' to plugin. It should work like 'skipTemplate' option while providing more skip/filtering methods.
Option should return an array of filters, matching available Kirby page filter methods arguments (except dates related ones for now).
Each filter will then be used to filter pages used for generation in d4l.static-site-generator api routes.
Examples
Motivation
When setting some routes in 'custom_routes' plugin option, for example
['path' => 'pagename', 'page' => 'folder/pagename']
, the page gets generated twice in/static
folder (at/static/folder/pagename/index.html
and/static/pagename/index.html
).When using endpoint or field method, we have no access to the $pages that get generated, and thus cannot prevent plugin from generating files in
/static/folder/
.In conjonction to such 'custom_routes', 'custom_filters' option could help in matching Kirby's dynamic routing behavior, for example Removing the parent page slug from the URL.
Full use-case
Possible enhancements
Testing
Tested with the two endpoints method