This article covers advanced information, and you are expected to already be familiar with Page Models and OOP
Abstract
This page contains the full API references for the built-in HydePage classes. Most users will not need to know about the inner workings of classes, but if you're interested in extending HydePHP, or just curious, this page is for you. It is especially useful if you're looking to implement your own page classes, or if you are creating advanced Blade templates.
About the reference
This document is heavily based around the actual source code, as I believe the best way to understand the code is to read it. However, large parts of the code are simplified for brevity and illustration. The code is not meant to be copy-pasted, but rather used as a reference so that you know what to look for in the actual source code, if you want to dig deeper.
Inheritance
Since all HydePages extend the base HydePage
class, those shared methods are only listed once,
under the HydePage
class documentation which is conveniently located just below this section.
Table of Contents
Class | Description |
---|---|
HydePage | The base class for all Hyde pages. |
BaseMarkdownPage | The base class for all Markdown pages. |
InMemoryPage | Extendable class for in-memory pages. |
BladePage | Class for Blade pages. |
MarkdownPage | Class for Markdown pages. |
MarkdownPost | Class for Markdown posts. |
DocumentationPage | Class for documentation pages. |
HtmlPage | Class for HTML pages. |
HydePage
The base class for all Hyde pages. All other page classes extend this class.
Unlike other frameworks, you generally don't instantiate pages yourself in Hyde. Instead, the page models act as blueprints defining information for Hyde to know how to parse a file, and what data around it should be generated.
To get a parsed file instance, you'd typically just create a source file, and you can then access the parsed file from the HydeKernel's page index.
In Blade views, you can always access the current page instance being rendered using the $page
variable.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
HydePage |
Hyde\Pages\Concerns |
Open in GitHub | Live API Docs |
Base Structure
/** * The base class for all Hyde pages. Here simplified for the sake of brevity. */abstract class HydePage{ /** * The directory in which source files are stored. Relative to the project root. */ public static string $sourceDirectory; /** * The output subdirectory to store compiled HTML. Relative to the _site output directory. */ public static string $outputDirectory; /** * The file extension of the source files. */ public static string $fileExtension; /** * The default template to use for rendering the page. */ public static string $template; /** * The page instance identifier. */ public readonly string $identifier; /** * The page instance route key. */ public readonly string $routeKey; /** * The parsed front matter. */ public FrontMatter $matter; /** * The generated page metadata. */ public PageMetadataBag $metadata; /** * The generated page navigation data. */ public NavigationData $navigation;}
Methods
Heads up! The following methods are defined in the
HydePage
class, and are thus available to all page classes. Since the HydePage class is abstract, you cannot instantiate it directly, and many of the static methods are also only callable from the child classes.
BaseMarkdownPage
The base class for all Markdown-based page models, with additional helpers tailored for Markdown pages.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
BaseMarkdownPage |
Hyde\Pages\Concerns |
Open in GitHub | Live API Docs |
Base Structure
/** * The base class for all Markdown-based page models. Here simplified for the sake of brevity. */abstract class BaseMarkdownPage extends HydePage{ public Markdown $markdown; public static string $fileExtension = '.md';}
Methods
InMemoryPage
Before we take a look at the common page classes, you'll usually use, let's first take a look at one that's quite interesting.
This class is especially useful for one-off custom pages. But if your usage grows, or if you want to utilize Hyde autodiscovery, you may benefit from creating a custom page class instead, as that will give you full control.
You can learn more about the InMemoryPage class in the InMemoryPage documentation.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
InMemoryPage |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
As the class is not discoverable, the static path properties are not initialized. Instead, you solely rely on the contents/view properties.
You can also define macros which allow you to both add methods to the instance, but also to overload some built-in ones like the compile
method.
/** * The InMemoryPage class, here simplified for the sake of brevity. */class InMemoryPage extends HydePage{ public static string $sourceDirectory; public static string $outputDirectory; public static string $fileExtension; protected string $contents; protected string $view; /** @var array<string, callable> */ protected array $macros = [];}
Methods
BladePage
Page class for Blade pages.
Blade pages are stored in the _pages
directory and using the .blade.php
extension.
They will be compiled using the Laravel Blade engine the _site/
directory.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
BladePage |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
class BladePage extends HydePage{ public static string $sourceDirectory = '_pages'; public static string $outputDirectory = ''; public static string $fileExtension = '.blade.php';}
Methods
MarkdownPage
Page class for Markdown pages.
Markdown pages are stored in the _pages
directory and using the .md
extension.
The Markdown will be compiled to HTML using a minimalistic layout to the _site/
directory.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
MarkdownPage |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
class MarkdownPage extends BaseMarkdownPage{ public static string $sourceDirectory = '_pages'; public static string $outputDirectory = ''; public static string $template = 'hyde::layouts/page';}
Methods
This class does not define any additional methods.
MarkdownPost
Page class for Markdown blog posts.
Markdown posts are stored in the _posts
directory and using the .md
extension.
The Markdown will be compiled to HTML using the blog post layout to the _site/posts/
directory.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
MarkdownPost |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
class MarkdownPost extends BaseMarkdownPage{ public static string $sourceDirectory = '_posts'; public static string $outputDirectory = 'posts'; public static string $template = 'hyde::layouts/post'; public ?string $description; public ?string $category; public ?DateString $date; public ?PostAuthor $author; public ?FeaturedImage $image;}
Methods
DocumentationPage
Page class for documentation pages.
Documentation pages are stored in the _docs
directory and using the .md
extension.
The Markdown will be compiled to HTML using the documentation page layout to the _site/docs/
directory.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
DocumentationPage |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
class DocumentationPage extends BaseMarkdownPage{ public static string $sourceDirectory = '_docs'; public static string $outputDirectory = 'docs'; public static string $template = 'hyde::layouts/docs';}
Methods
HtmlPage
Page class for HTML pages.
HTML pages are stored in the _pages
directory and using the .html
extension.
These pages will be copied exactly as they are to the _site/
directory.
Quick Reference
Class Name | Namespace | Source Code | API Docs |
---|---|---|---|
HtmlPage |
Hyde\Pages |
Open in GitHub | Live API Docs |
Base Structure
class HtmlPage extends HydePage{ public static string $sourceDirectory = '_pages'; public static string $outputDirectory = ''; public static string $fileExtension = '.html';}