Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider changing HydePage::get() method to be static and return an instance instead of data from within #709

Closed
caendesilva opened this issue Nov 27, 2022 · 1 comment · Fixed by #713

Comments

@caendesilva
Copy link
Member

caendesilva commented Nov 27, 2022

Most times we use the get method, it's as a facade/helper to get an existing object. See the Route model for example:

public static function get(string $routeKey): ?\Hyde\Support\Models\Route
{
return \Hyde\Support\Models\Route::get($routeKey);
}

However, the Hyde pages get method returns data from the front matter.

/**
* Get a value from the computed page data, or fallback to the page's front matter, then to the default value.
*
* @return \Hyde\Markdown\Models\FrontMatter|mixed
*/
public function get(string $key = null, mixed $default = null): mixed

I think it would make more sense to normalize the usage to also use get statically for Hyde pages. And since we have an existing alias for the get method already it should be an easy enough migration (while it is still breaking) Edit: My bad, the other method is not an alias, so I think the current get method could be renamed to data

public function matter(string $key = null, mixed $default = null): mixed
{
return $this->matter->get($key, $default);
}

@caendesilva
Copy link
Member Author

I think this was originally made this way to match the FrontMatter class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant