Skip to content

make()

Create a new page instance. Static alias for the constructor.

HydePage::make(string $identifier, Hyde\Markdown\Models\FrontMatter|array $matter): static

isDiscoverable()

Returns whether the page type is discoverable through auto-discovery.

HydePage::isDiscoverable(): bool

get()

Get a page instance from the Kernel's page index by its identifier.

HydePage::get(string $identifier): static
  • Throws: \Hyde\Framework\Exceptions\FileNotFoundException If the page does not exist.

parse()

Parse a source file into a new page model instance.

/** @param string $identifier The identifier of the page to parse. */
HydePage::parse(string $identifier): static // New page model instance for the parsed source file.
  • Throws: \Hyde\Framework\Exceptions\FileNotFoundException If the file does not exist.

files()

Get an array of all the source file identifiers for the model.

Note that the values do not include the source directory or file extension.

HydePage::files(): array<string>

all()

Get a collection of all pages, parsed into page models.

HydePage::all(): \Hyde\Foundation\Kernel\PageCollection<static>

sourceDirectory()

Get the directory where source files are stored for the page type.

HydePage::sourceDirectory(): string

outputDirectory()

Get the output subdirectory to store compiled HTML files for the page type.

HydePage::outputDirectory(): string

fileExtension()

Get the file extension of the source files for the page type.

HydePage::fileExtension(): string

setSourceDirectory()

Set the output directory for the page type.

HydePage::setSourceDirectory(string $sourceDirectory): void

setOutputDirectory()

Set the source directory for the page type.

HydePage::setOutputDirectory(string $outputDirectory): void

setFileExtension()

Set the file extension for the page type.

HydePage::setFileExtension(string $fileExtension): void

sourcePath()

Qualify a page identifier into file path to the source file, relative to the project root.

HydePage::sourcePath(string $identifier): string

outputPath()

Qualify a page identifier into a target output file path, relative to the _site output directory.

HydePage::outputPath(string $identifier): string

path()

Get an absolute file path to the page's source directory, or a file within it.

HydePage::path(string $path): string

pathToIdentifier()

Format a filename to an identifier for a given model. Unlike the basename function, any nested paths within the source directory are retained in order to satisfy the page identifier definition.

/** @param string $path Example: index.blade.php */
HydePage::pathToIdentifier(string $path): string // Example: index

baseRouteKey()

Get the route key base for the page model.

This is the same value as the output directory.

HydePage::baseRouteKey(): string

__construct()

Construct a new page instance.

$page = new HydePage(string $identifier, Hyde\Markdown\Models\FrontMatter|array $matter): void

compile()

Compile the page into static HTML.

$page->compile(): string // The compiled HTML for the page.

toArray()

Get the instance as an array.

$page->toArray(): array

getSourcePath()

Get the path to the instance source file, relative to the project root.

$page->getSourcePath(): string

getOutputPath()

Get the path where the compiled page will be saved.

$page->getOutputPath(): string // Path relative to the site output directory.

getRouteKey()

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.

$page->getRouteKey(): string

getRoute()

Get the route object for the page.

$page->getRoute(): Hyde\Support\Models\Route

getLink()

Format the page instance to a URL path, with support for pretty URLs if enabled.

Note that the link is always relative to site root, and does not contain ../ segments.

$page->getLink(): string

getIdentifier()

Get the page model's identifier property.

The identifier is the part between the source directory and the file extension. It may also be known as a 'slug', or previously 'basename', but it retains the nested path structure if the page is stored in a subdirectory.

For example, the identifier of a source file stored as '_pages/about/contact.md' would be 'about/contact', and 'pages/about.md' would simply be 'about'.

$page->getIdentifier(): string

getBladeView()

Get the Blade template/view key for the page.

$page->getBladeView(): string

title()

Get the page title to display in HTML tags like <title> and <meta> tags.

$page->title(): string

metadata()

Get the generated metadata for the page.

$page->metadata(): Hyde\Framework\Features\Metadata\PageMetadataBag

showInNavigation()

Can the page be shown in the navigation menu?

$page->showInNavigation(): bool

navigationMenuPriority()

Get the priority of the page in the navigation menu.

$page->navigationMenuPriority(): int

navigationMenuLabel()

Get the label of the page in the navigation menu.

$page->navigationMenuLabel(): string

navigationMenuGroup()

Get the group of the page in the navigation menu, if any.

$page->navigationMenuGroup(): string

getCanonicalUrl()

Get the canonical URL for the page to use in the <link rel=&quot;canonical&quot;> tag.

It can be explicitly set in the front matter using the canonicalUrl key, otherwise it will be generated based on the site URL and the output path, unless there is no configured base URL, leading to this returning null.

$page->getCanonicalUrl(): string