diff --git a/README.md b/README.md index 4ca2d9b..e9b3334 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,17 @@ You may configure a custom routing style in `config/statamic/ssg.php`: 'pagination_route' => '{url}/{page_name}/{page_number}', ``` +## Views + +You can tell if the SSG was running from your templates by using the following check. + +This is antlers, but the same principle will work for any conditional checking the `statamic.ssg.running` config key: + +``` +{{ if ! config:statamic:ssg:running }} + +{{ /if }} +``` ## Post-generation callback diff --git a/phpunit.xml b/phpunit.xml index bfc27ff..2adcc5a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,24 +1,16 @@ - - - - ./tests - - - - - - - - - - + + + + ./tests + + + + + + + + + + diff --git a/src/Commands/StaticSiteGenerate.php b/src/Commands/StaticSiteGenerate.php index 0660f00..8bf823a 100644 --- a/src/Commands/StaticSiteGenerate.php +++ b/src/Commands/StaticSiteGenerate.php @@ -55,6 +55,8 @@ public function handle() { Partyline::bind($this); + config(['statamic.ssg.running' => true]); + if (config('statamic.editions.pro') && ! config('statamic.system.license_key')) { $this->error('Statamic Pro is enabled but no site license was found.'); $this->warn('Please set a valid Statamic License Key in your .env file.'); diff --git a/tests/Concerns/RunsGeneratorCommand.php b/tests/Concerns/RunsGeneratorCommand.php index 1b12e7c..a5deec3 100644 --- a/tests/Concerns/RunsGeneratorCommand.php +++ b/tests/Concerns/RunsGeneratorCommand.php @@ -34,6 +34,8 @@ protected function generate($options = []) $this->assertTrue($this->files->exists($this->destination)); + $this->assertTrue(app('config')->get('statamic.ssg.running')); + return $this->getGeneratedFilesAtPath($this->destination); }