Skip to content

Commit

Permalink
get content in folder off root
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbruce committed Oct 15, 2021
1 parent f3304fa commit 631a878
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ public function navigation(string $fileName = 'main.md'): array
return [];
}

/**
* @param string $folder [description]
* @return array<Item> [description]
*/
public function folderContent(string $folder): array
{
$item = Item::create($this->root)->append($folder);
if ($item->isFolder()) {
$c = $item->content();
if (is_array($c)) {
return $c;

}
}
return [];
}

private function item(string ...$append): Item
{
$extendedTail = array_merge($this->tail(), $append);
Expand Down
11 changes: 11 additions & 0 deletions tests/StoreBaselineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
);
});

test('Folder content', function() {
$this->assertEquals(
Store::create($this->root)->folderContent('.navigation'),
[
Item::create($this->root)->append('.navigation', 'footer.md'),
Item::create($this->root)->append('.navigation', 'primary.md'),
Item::create($this->root)->append('.navigation', 'tiered.md'),
]
);
});

test('Navigation shorthand', function() {
expect(
Store::create($this->root)->navigation('primary.md')
Expand Down

0 comments on commit 631a878

Please sign in to comment.