Skip to content

Commit

Permalink
Merge pull request #361 from hydephp/fix-inspection-issues
Browse files Browse the repository at this point in the history
Add getIdentifier() method to PageContract and AbstractPage hydephp/develop@118b889
  • Loading branch information
github-actions committed Aug 7, 2022
1 parent 4fbcb80 commit 5413ecf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Contracts/AbstractPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public function matter(string $key = null, mixed $default = null): mixed
return $this->matter->get($key, $default);
}

/** @inheritDoc */
public function getIdentifier(): string
{
return $this->identifier;
}

/** @inheritDoc */
public function getSourcePath(): string
{
Expand Down
7 changes: 7 additions & 0 deletions src/Contracts/PageContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public static function qualifyBasename(string $basename): string;
*/
public static function getOutputLocation(string $basename): string;

/**
* Get the page model's identifier property.
*
* @return string The page's identifier/slug.
*/
public function getIdentifier(): string;

/**
* Get the path to the source file, relative to the project root.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Services/SitemapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function addRoute(RouteContract $route): void
$urlItem->addChild('lastmod', htmlentities($this->getLastModDate($route->getSourceFilePath())));
$urlItem->addChild('changefreq', 'daily');
if (config('hyde.sitemap.dynamic_priority', true)) {
$urlItem->addChild('priority', $this->getPriority($route->getPageType(), $route->getSourceModel()->identifier));
$urlItem->addChild('priority', $this->getPriority($route->getPageType(), $route->getSourceModel()->getIdentifier()));
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/AbstractPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public function test_get_file_extension_forces_leading_period()
$this->assertEquals('.foo', MarkdownPage::getFileExtension());
}

public function test_get_identifier_returns_identifier_property()
{
$page = new MarkdownPage('foo');
$this->assertEquals('foo', $page->getIdentifier());
}

public function test_parse_parses_supplied_slug_into_a_page_model()
{
Hyde::touch(('_pages/foo.md'));
Expand Down

0 comments on commit 5413ecf

Please sign in to comment.