Skip to content

Commit

Permalink
Allow wildcards in excludes (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
tao authored Dec 10, 2020
1 parent 0636076 commit ead8bfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Install the package using Composer:
composer require statamic/ssg
```

If you want or need to customize the way the site is generated, you can do so by publishing and modifying the config file with the following command:
If you want or need to customize the way the site is generated, you can do so by publishing and modifying the config file with the following command:

```
php artisan vendor:publish --provider="Statamic\StaticSite\ServiceProvider"
Expand Down Expand Up @@ -50,6 +50,14 @@ Routes will not automatically be generated. You can add any additional URLs you
],
```

You can also exclude single routes, or route groups with wildcards. This will override anything in the `urls` config.

``` php
'exclude' => [
'/secret-page',
'/cheat-codes/*',
],
```

## Post-generation callback

Expand Down
6 changes: 6 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ protected function pages()
->merge($this->scopedTerms())
->values()
->reject(function ($page) {
foreach ($this->config['exclude'] as $url) {
if (Str::endsWith($url, '*')) {
if (Str::is($url, $page->url())) return true;
}
}

return in_array($page->url(), $this->config['exclude']);
})->sortBy(function ($page) {
return str_replace('/', '', $page->url());
Expand Down

0 comments on commit ead8bfa

Please sign in to comment.