Skip to content

Commit 7db6a59

Browse files
committed
Add option for pretty urls fix #330
1 parent 550edf7 commit 7db6a59

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/Commands/HydeBuildStaticSiteCommand.php

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class HydeBuildStaticSiteCommand extends Command
3636
{--run-dev : Run the NPM dev script after build}
3737
{--run-prod : Run the NPM prod script after build}
3838
{--pretty : Should the build files be prettified?}
39+
{--pretty-urls : Should links in output use pretty URLs?}
3940
{--no-api : Disable external API calls, such as Torchlight}';
4041

4142
/**
@@ -97,6 +98,12 @@ protected function printInitialInformation(): void
9798
unset($config[array_search('torchlight', $config)]);
9899
Config::set(['hyde.features' => $config]);
99100
}
101+
102+
if ($this->option('pretty-urls')) {
103+
$this->info('Generating site with pretty URLs');
104+
$this->newLine();
105+
Config::set(['hyde.prettyUrls' => true]);
106+
}
100107
}
101108

102109
/** @internal */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Tests\Unit;
4+
5+
use Hyde\Framework\Hyde;
6+
use Tests\TestCase;
7+
8+
/**
9+
* Class TestBuildStaticSiteCommandFlagToEnablePrettyUrls.
10+
*/
11+
class TestBuildStaticSiteCommandFlagToEnablePrettyUrls extends TestCase
12+
{
13+
public function test_pretty_urls_can_be_enabled_with_flag()
14+
{
15+
config(['hyde.prettyUrls' => false]);
16+
17+
$this->artisan('build --pretty-urls')
18+
->expectsOutput('Generating site with pretty URLs')
19+
->assertExitCode(0);
20+
21+
$this->assertTrue(config('hyde.prettyUrls', false));
22+
}
23+
24+
public function test_config_change_is_not_persisted()
25+
{
26+
$this->assertFalse(config('hyde.prettyUrls', false));
27+
}
28+
}

0 commit comments

Comments
 (0)