diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7bea4c45323..e4c43f306b0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -25,7 +25,7 @@ This serves two purposes: - Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task. - Media asset files are now copied using the new build task instead of the deprecated `BuildService::transferMediaAssets()` method. - Calling the `Include::path()` method will no longer create the includes directory in https://github.com/hydephp/develop/pull/1707 - +- Calling the `DataCollections` methods will no longer create the data collections directory in https://github.com/hydephp/develop/pull/1732 ### Deprecated - for soon-to-be removed features. @@ -223,3 +223,5 @@ For example, if you triggered the media transfer with a build service method cal The DataCollections feature has been reworked to improve the developer experience and make it more consistent with the rest of the API. Unfortunately, this means that existing setups may need to be adjusted to work with the new API. + +- Calling the `DataCollections` methods will no longer create the data collections directory automatically diff --git a/docs/digging-deeper/collections.md b/docs/digging-deeper/collections.md index 89745bd0c57..b83bef6647f 100644 --- a/docs/digging-deeper/collections.md +++ b/docs/digging-deeper/collections.md @@ -32,7 +32,6 @@ Follow these conventions and creating dynamic static sites will be a breeze. 6. While not enforced, each subdirectory should probably only have the same filetype to prevent developer confusion. 7. Unlike source files for pages, files starting with underscores are not ignored. 8. You can customize the source directory for collections through a service provider. -9. If the base source directory does not exist, it will be created for you. ## Available Collection Types diff --git a/packages/framework/src/Support/DataCollections.php b/packages/framework/src/Support/DataCollections.php index 79e53dc32d5..00d54371089 100644 --- a/packages/framework/src/Support/DataCollections.php +++ b/packages/framework/src/Support/DataCollections.php @@ -8,7 +8,6 @@ use Symfony\Component\Yaml\Yaml; use Hyde\Markdown\Models\FrontMatter; use Hyde\Framework\Actions\MarkdownFileParser; -use Hyde\Framework\Concerns\InteractsWithDirectories; use Illuminate\Support\Collection; use Illuminate\Support\Str; @@ -35,8 +34,6 @@ */ class DataCollections extends Collection { - use InteractsWithDirectories; - /** * The base directory for all data collections. Can be modified using a service provider. */ @@ -51,8 +48,6 @@ class DataCollections extends Collection */ public static function markdown(string $name): static { - static::needsDirectory(static::$sourceDirectory); - return new static(static::findFiles($name, 'md')->mapWithKeys(function (string $file): array { return [static::makeIdentifier($file) => MarkdownFileParser::parse($file)]; })); @@ -67,8 +62,6 @@ public static function markdown(string $name): static */ public static function yaml(string $name): static { - static::needsDirectory(static::$sourceDirectory); - return new static(static::findFiles($name, ['yaml', 'yml'])->mapWithKeys(function (string $file): array { $content = Filesystem::get($file); $content = Str::between($content, '---', '---'); @@ -89,8 +82,6 @@ public static function yaml(string $name): static */ public static function json(string $name, bool $asArray = false): static { - static::needsDirectory(static::$sourceDirectory); - return new static(static::findFiles($name, 'json')->mapWithKeys(function (string $file) use ($asArray): array { return [static::makeIdentifier($file) => json_decode(Filesystem::get($file), $asArray)]; })); diff --git a/packages/framework/tests/Feature/DataCollectionTest.php b/packages/framework/tests/Feature/DataCollectionTest.php index bea53f0ef6d..f144e9fd367 100644 --- a/packages/framework/tests/Feature/DataCollectionTest.php +++ b/packages/framework/tests/Feature/DataCollectionTest.php @@ -4,12 +4,10 @@ namespace Hyde\Framework\Testing\Feature; -use Hyde\Hyde; use Hyde\Markdown\Models\FrontMatter; use Hyde\Markdown\Models\MarkdownDocument; use Hyde\Support\DataCollections; use Hyde\Testing\TestCase; -use Illuminate\Support\Facades\File; /** * @covers \Hyde\Support\DataCollections @@ -170,30 +168,4 @@ public function testSourceDirectoryCanBeChanged() DataCollections::$sourceDirectory = 'resources/collections'; } - - public function testSourceDirectoryIsAutomaticallyAddedIfMissing() - { - $this->directory('resources/collections'); - File::deleteDirectory(Hyde::path('resources/collections')); - $this->assertDirectoryDoesNotExist(Hyde::path('resources/collections')); - - DataCollections::markdown('foo'); - - $this->assertDirectoryExists(Hyde::path('resources/collections')); - } - - public function testCustomSourceDirectoryIsAutomaticallyAddedIfMissing() - { - $this->directory('foo'); - File::deleteDirectory(Hyde::path('foo')); - - $this->assertDirectoryDoesNotExist(Hyde::path('foo')); - - DataCollections::$sourceDirectory = 'foo'; - DataCollections::markdown('bar'); - - $this->assertDirectoryExists(Hyde::path('foo')); - - DataCollections::$sourceDirectory = 'resources/collections'; - } }