Skip to content

Commit

Permalink
Merge pull request #605 from hydephp/xml-generator-bugfixes
Browse files Browse the repository at this point in the history
Fix issues with the sitemap and RSS feed generator commands
  • Loading branch information
caendesilva authored Apr 12, 2024
2 parents 681810f + 9ee1a9d commit 63c6dfa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/Framework/Actions/PostBuildTasks/GenerateRssFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@

use Hyde\Hyde;
use Hyde\Framework\Features\BuildTasks\PostBuildTask;
use Hyde\Framework\Concerns\InteractsWithDirectories;
use Hyde\Framework\Features\XmlGenerators\RssFeedGenerator;

use function file_put_contents;

class GenerateRssFeed extends PostBuildTask
{
use InteractsWithDirectories;

public static string $message = 'Generating RSS feed';

protected string $path;

public function handle(): void
{
file_put_contents(
Hyde::sitePath(RssFeedGenerator::getFilename()),
RssFeedGenerator::make()
);
$this->path = Hyde::sitePath(RssFeedGenerator::getFilename());

$this->needsParentDirectory($this->path);

file_put_contents($this->path, RssFeedGenerator::make());
}

public function printFinishMessage(): void
{
$this->createdSiteFile('_site/'.RssFeedGenerator::getFilename())->withExecutionTime();
$this->createdSiteFile($this->path)->withExecutionTime();
}
}
16 changes: 11 additions & 5 deletions src/Framework/Actions/PostBuildTasks/GenerateSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@

use Hyde\Hyde;
use Hyde\Framework\Features\BuildTasks\PostBuildTask;
use Hyde\Framework\Concerns\InteractsWithDirectories;
use Hyde\Framework\Features\XmlGenerators\SitemapGenerator;

use function file_put_contents;

class GenerateSitemap extends PostBuildTask
{
use InteractsWithDirectories;

public static string $message = 'Generating sitemap';

protected string $path;

public function handle(): void
{
file_put_contents(
Hyde::sitePath('sitemap.xml'),
SitemapGenerator::make()
);
$this->path = Hyde::sitePath('sitemap.xml');

$this->needsParentDirectory($this->path);

file_put_contents($this->path, SitemapGenerator::make());
}

public function printFinishMessage(): void
{
$this->createdSiteFile('_site/sitemap.xml')->withExecutionTime();
$this->createdSiteFile($this->path)->withExecutionTime();
}
}

0 comments on commit 63c6dfa

Please sign in to comment.