diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index efadf4218a8..3fe3f8ef0a5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -25,6 +25,7 @@ This serves two purposes: - for now removed features. ### Fixed +- Fixed a bug where the sitemap and RSS feed generator commands did not work when the `_site/` directory was not present in https://github.com/hydephp/develop/pull/1654 - Realtime Compiler: Fixed responsive dashboard table issue in https://github.com/hydephp/develop/pull/1595 ### Security diff --git a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateRssFeed.php b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateRssFeed.php index ba67a2d62b9..e974d12906b 100644 --- a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateRssFeed.php +++ b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateRssFeed.php @@ -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(); } } diff --git a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSitemap.php b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSitemap.php index b45aa2df88b..7e9f54ac3e1 100644 --- a/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSitemap.php +++ b/packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSitemap.php @@ -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(); } }