Skip to content

Commit

Permalink
Get the page's route from the route index
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 8, 2022
1 parent 0cadd8c commit a41fa35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/framework/src/Pages/Concerns/HydePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function getRouteKey(): string
*/
public function getRoute(): Route
{
return new Route($this);
return \Hyde\Facades\Route::get($this->getRouteKey());
}

/**
Expand Down
7 changes: 7 additions & 0 deletions packages/framework/tests/Feature/HydePageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ public function test_get_route_returns_page_route()
$this->assertEquals(new Route($page), $page->getRoute());
}

public function test_get_route_returns_the_route_object_from_the_router_index()
{
$this->file('_pages/foo.md');
$page = MarkdownPage::parse('foo');
$this->assertSame(\Hyde\Facades\Route::get('foo'), $page->getRoute());
}

public function test_html_title_returns_site_name_plus_page_title()
{
$this->assertEquals('HydePHP - Foo', MarkdownPage::make('', ['title' => 'Foo'])->htmlTitle());
Expand Down

0 comments on commit a41fa35

Please sign in to comment.