Skip to content

Commit

Permalink
Breaking: Rename class Route to PageRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Mar 24, 2024
1 parent dc8d4cb commit d5fa496
Show file tree
Hide file tree
Showing 75 changed files with 283 additions and 283 deletions.
2 changes: 1 addition & 1 deletion _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/** @var \Hyde\Pages\Concerns\HydePage $page The page being compiled/previewed */
$page = \Hyde\Support\Facades\Render::getPage();

/** @var \Hyde\Support\Models\Route $route The route for the page being compiled/previewed */
/** @var \Hyde\Support\Models\PageRoute $route The route for the page being compiled/previewed */
$route = \Hyde\Support\Facades\Render::getRoute();

/** @var string $routeKey The route key for the page being compiled/previewed */
Expand Down
2 changes: 1 addition & 1 deletion config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
|
| If you are looking to customize the main navigation menu, this is the place!
|
| All these settings uses Route Keys to identify the page you want to configure.
| All these settings uses PageRoute Keys to identify the page you want to configure.
| A route key is simply the URL path to the page, without the file extension.
| So `_site/posts/hello-world.html` has the route key 'posts/hello-world'.
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ No description provided.

```php
// torchlight! {"lineNumbers": false}
DocumentationPage::home(): Hyde\Support\Models\Route
DocumentationPage::home(): Hyde\Support\Models\PageRoute
```

#### `homeRouteName()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ No description provided.

```php
// torchlight! {"lineNumbers": false}
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route>
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\PageRoute>
```

<!-- End generated docs for Hyde\Foundation\Concerns\HandlesFoundationCollections -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ No description provided.

```php
// torchlight! {"lineNumbers": false}
Hyde::route(string $key): Hyde\Support\Models\Route
Hyde::route(string $key): Hyde\Support\Models\PageRoute
```

#### `hasSiteUrl()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Get the route for the page being rendered.

```php
// torchlight! {"lineNumbers": false}
Hyde::currentRoute(): Hyde\Support\Models\Route
Hyde::currentRoute(): Hyde\Support\Models\PageRoute
```

#### `currentPage()`
Expand Down
4 changes: 2 additions & 2 deletions docs/_data/partials/hyde-pages-api/hyde-page-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Get the route key for the page.

The route key is the page URL path, relative to the site root, but without any file extensions. For example, if the page will be saved to `_site/docs/index.html`, the key is `docs/index`.

Route keys are used to identify page routes, similar to how named routes work in Laravel, only that here the name is not just arbitrary, but also defines the output location, as the route key is used to determine the output path which is `$routeKey.html`.
PageRoute keys are used to identify page routes, similar to how named routes work in Laravel, only that here the name is not just arbitrary, but also defines the output location, as the route key is used to determine the output path which is `$routeKey.html`.

```php
// torchlight! {"lineNumbers": false}
Expand All @@ -230,7 +230,7 @@ Get the route object for the page.

```php
// torchlight! {"lineNumbers": false}
$page->getRoute(): Hyde\Support\Models\Route
$page->getRoute(): Hyde\Support\Models\PageRoute
```

#### `getLink()`
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture-concepts/automatic-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ php hyde route:list

### Accessing routes

Each route in your site is represented by a Route object. It's very easy to get a Route object instance from the Router's index.
Each route in your site is represented by a PageRoute object. It's very easy to get a PageRoute object instance from the Router's index.
There are a few ways to do this, but most commonly you'll use the Routes facade's `get()` method where you provide a route key,
and it will return the Route object. The route key is generally `<page-output-directory/page-identifier>`. Here are some examples:
and it will return the PageRoute object. The route key is generally `<page-output-directory/page-identifier>`. Here are some examples:

```php
// Source file: _pages/index.md/index.blade.php
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture-concepts/the-hydekernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ No description provided.

```php
// torchlight! {"lineNumbers": false}
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route>
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\PageRoute>
```

<!-- End generated docs for Hyde\Foundation\Concerns\HandlesFoundationCollections -->
Expand Down Expand Up @@ -546,7 +546,7 @@ Get the route for the page being rendered.

```php
// torchlight! {"lineNumbers": false}
Hyde::currentRoute(): Hyde\Support\Models\Route
Hyde::currentRoute(): Hyde\Support\Models\PageRoute
```

#### `currentPage()`
Expand Down
4 changes: 2 additions & 2 deletions docs/digging-deeper/advanced-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function register(): void
## Customizing Output Directories

Like source directories, the output directories are also important as they determine the output path for the compiled pages.
>warning Note that changing output directories also affects the route keys, as those are based on the output directory. <p>Scroll down to see the [Route key impact](#route-key-impact) section for more information.</p>
>warning Note that changing output directories also affects the route keys, as those are based on the output directory. <p>Scroll down to see the [PageRoute key impact](#route-key-impact) section for more information.</p>
Each option is relative to the site's `output_directory` setting. Setting a value to `''` will output the page to the site root.

Expand Down Expand Up @@ -109,7 +109,7 @@ public function register(): void
}
```

### Route key impact
### PageRoute key impact

For example, changing the output directory of Markdown posts to `blog` instead of `posts` will change the route key base from `posts` to `blog`.
This means that a file stored as `_posts/hello-world.md` will have the route key `blog/hello-world` instead of `posts/hello-world`,
Expand Down
2 changes: 1 addition & 1 deletion docs/digging-deeper/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ This is an alias of the `Hyde::route()` facade method and allows you to get a ro
route('index'); // Returns the route instance with the given key
```

If a route does not exist, `null` will be returned. Route instances can be cast to strings to resolve a link to the page.
If a route does not exist, `null` will be returned. PageRoute instances can be cast to strings to resolve a link to the page.

**Example usage:**

Expand Down
2 changes: 1 addition & 1 deletion docs/digging-deeper/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ We will use the following definitions to describe the behaviour of Hyde.
#### Path components

- **Identifier**: The filepath without the extension, relative to the page type source directory.
- **Route Key**: The page type's output directory plus the identifier. Example: `posts/hello-world`
- **PageRoute Key**: The page type's output directory plus the identifier. Example: `posts/hello-world`
- **Basename**: The filename without the extension. Example: `hello-world`
- **Filename**: The full name of a file with the extension. Example: `hello-world.md`
- **Filepath**: The full file path including extension. Example: `_posts/hello-world.md`
Expand Down
20 changes: 10 additions & 10 deletions docs/getting-started/core-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ All source and output directories are configurable, but the defaults are as foll
| Media Assets | `_media/` | `_site/media/` | Common asset types |


## Paths, Identifiers, and Route Keys
## Paths, Identifiers, and PageRoute Keys

Since HydePHP automatically discovers and compiles content files, it is important to understand how HydePHP handles paths,
as the file names and directories they are in will directly influence how the page will be compiled.
Expand All @@ -87,7 +87,7 @@ As such, it will be helpful for you to know about the following terms:

- **Path:** The full path to a file, including the file name, directory, and extension.
- **Identifier:** The unique identifier for a page. Unique only within the same page type.
- **Route key:** The key used to access the page in the routing system. Unique across all site pages.
- **PageRoute key:** The key used to access the page in the routing system. Unique across all site pages.

Both the identifier and route key are derived from the path of the page. The identifier is the path without the file
extension, and relative to the page type source directory. The route key is the output directory plus the identifier.
Expand Down Expand Up @@ -180,8 +180,8 @@ During the build of each page, Hyde will inject some data available to all Blade
any custom Blade templates, you can safely ignore this section. If you are, here are the three global variables you can use:

- `$page`: The [Page Object](#page-models) for the current page.
- `$route`: The [Route Object](#automatic-routing) for the current page.
- `$routeKey`: The [Route Key](#paths-identifiers-and-route-keys) for the current page.
- `$route`: The [PageRoute Object](#automatic-routing) for the current page.
- `$routeKey`: The [PageRoute Key](#paths-identifiers-and-route-keys) for the current page.

The `$page` variable is likely to the most important one, as it contains all the data for the current page.
Depending on the page type, you will have different helpers available. But `$page->matter()` is likely to be very helpful.
Expand Down Expand Up @@ -240,7 +240,7 @@ This will help you understand the documentation and codebase better, as well as
- [Page Types](#page-types)
- [Page Identifiers](#page-identifiers)
- [Routes](#routes)
- [Route Keys](#route-keys)
- [PageRoute Keys](#route-keys)

</div>

Expand Down Expand Up @@ -325,7 +325,7 @@ Content files, including Markdown and Blade files, are automatically discovered
During autodiscovery, Hyde also generates dynamic data to enrich your content based on the page type.

In short the autodiscovery is split into three steps:
`File discovery -> Page parsing -> Route generation`
`File discovery -> Page parsing -> PageRoute generation`

### Page Types

Expand All @@ -339,13 +339,13 @@ The identifier is used to generate the route key, which is used to generate the

### Routes

All pages are internally bound to a Route object, through the route key. During the build process, each route is
All pages are internally bound to a PageRoute object, through the route key. During the build process, each route is
compiled to HTML using the page object's data, and saved to the output directory with a file name created from the route key.
Since routes are generated automatically during autodiscovery, there is no need to create them manually.

### Route Keys
### PageRoute Keys

The route key is the URL path relative to the site webroot, without the file extension. The route key is the common
identifier binding Page objects to Route objects, and is used to generate the file name for the compiled HTML file.
identifier binding Page objects to PageRoute objects, and is used to generate the file name for the compiled HTML file.

Route keys generation can be visualised as follows: `<PageClass::OutputDirectory>/<PageIdentifier>`
PageRoute keys generation can be visualised as follows: `<PageClass::OutputDirectory>/<PageIdentifier>`
2 changes: 1 addition & 1 deletion packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
|
| If you are looking to customize the main navigation menu, this is the place!
|
| All these settings uses Route Keys to identify the page you want to configure.
| All these settings uses PageRoute Keys to identify the page you want to configure.
| A route key is simply the URL path to the page, without the file extension.
| So `_site/posts/hello-world.html` has the route key 'posts/hello-world'.
|
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Console/Commands/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Hyde\Console\Concerns\Command;
use Hyde\Hyde;
use Hyde\Pages\InMemoryPage;
use Hyde\Support\Models\Route;
use Hyde\Support\Models\PageRoute;
use Hyde\Support\Models\RouteList;
use Hyde\Support\Models\RouteListItem;

Expand Down Expand Up @@ -38,7 +38,7 @@ protected function routeListClass(): RouteList
{
return new class extends RouteList
{
protected static function routeToListItem(Route $route): RouteListItem
protected static function routeToListItem(PageRoute $route): RouteListItem
{
return new class($route) extends RouteListItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Hyde\Foundation\Concerns;

use Hyde\Support\Models\Route;
use Hyde\Support\Models\PageRoute;

/**
* @internal Single-use trait for the HydeKernel class.
Expand Down Expand Up @@ -38,7 +38,7 @@ public function url(string $path = ''): string
return $this->hyperlinks->url($path);
}

public function route(string $key): ?Route
public function route(string $key): ?PageRoute
{
return $this->hyperlinks->route($key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function pages(): PageCollection
return $this->pages;
}

/** @return \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route> */
/** @return \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\PageRoute> */
public function routes(): RouteCollection
{
$this->needsToBeBooted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Hyde\Pages\Concerns\HydePage;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\Route;
use Hyde\Support\Models\PageRoute;

/**
* @internal Single-use trait for the HydeKernel class.
Expand Down Expand Up @@ -34,7 +34,7 @@ public function currentRouteKey(): ?string
/**
* Get the route for the page being rendered.
*/
public function currentRoute(): ?Route
public function currentRoute(): ?PageRoute
{
return Render::getRoute();
}
Expand Down
12 changes: 6 additions & 6 deletions packages/framework/src/Foundation/Facades/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Hyde\Foundation\HydeKernel;
use Hyde\Foundation\Kernel\RouteCollection;
use Hyde\Hyde;
use Hyde\Support\Models\Route;
use Hyde\Support\Models\PageRoute;
use Illuminate\Support\Facades\Facade;

/**
Expand All @@ -19,7 +19,7 @@
*/
class Routes extends Facade
{
/** @return \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route> */
/** @return \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\PageRoute> */
public static function getFacadeRoot(): RouteCollection
{
return HydeKernel::getInstance()->routes();
Expand All @@ -30,25 +30,25 @@ public static function exists(string $routeKey): bool
return static::getFacadeRoot()->has($routeKey);
}

public static function get(string $routeKey): ?Route
public static function get(string $routeKey): ?PageRoute
{
return static::getFacadeRoot()->get($routeKey);
}

/** @throws \Hyde\Framework\Exceptions\RouteNotFoundException */
public static function getOrFail(string $routeKey): Route
public static function getOrFail(string $routeKey): PageRoute
{
return static::getFacadeRoot()->getRoute($routeKey);
}

/** @return \Hyde\Foundation\Kernel\RouteCollection<\Hyde\Support\Models\Route> */
/** @return \Hyde\Foundation\Kernel\RouteCollection<\Hyde\Support\Models\PageRoute> */
public static function all(): RouteCollection
{
return static::getFacadeRoot()->getRoutes();
}

/** Get the current route for the page being rendered. */
public static function current(): ?Route
public static function current(): ?PageRoute
{
return Hyde::currentRoute();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Foundation/Kernel/Hyperlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Hyde\Foundation\Kernel;

use Hyde\Facades\Config;
use Hyde\Support\Models\Route;
use Hyde\Support\Models\PageRoute;
use Hyde\Foundation\HydeKernel;
use Hyde\Framework\Exceptions\BaseUrlNotSetException;
use Hyde\Framework\Exceptions\FileNotFoundException;
Expand Down Expand Up @@ -153,7 +153,7 @@ public function url(string $path = ''): string
/**
* Get a route instance by its key from the kernel's route collection.
*/
public function route(string $key): ?Route
public function route(string $key): ?PageRoute
{
return $this->kernel->routes()->get($key);
}
Expand Down
Loading

0 comments on commit d5fa496

Please sign in to comment.