API Documentation

MarkdownPost extends BaseMarkdownPage
in package
implements BlogPostSchema

Page class for Markdown 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.

Tags
see
https://hydephp.com/docs/1.x/blog-posts

Table of Contents

Interfaces

BlogPostSchema
Front matter schema interfaces are used by various Hyde components to specify what data they provide or contain. They also serve as a convenient way to see the supported front matter properties.

Properties

$author  : PostAuthor|null
$category  : string|null
$date  : DateString|null
$description  : string|null
$fileExtension  : string
$identifier  : string
$image  : FeaturedImage|null
$markdown  : Markdown
$matter  : FrontMatter
$metadata  : PageMetadataBag
$navigation  : NavigationData
$outputDirectory  : string
$routeKey  : string
$sourceDirectory  : string
$template  : string
$title  : string

Methods

__construct()  : mixed
Construct a new page instance.
all()  : PageCollection<string|int, static>
Get a collection of all pages, parsed into page models.
arraySerialize()  : array<string|int, mixed>
Recursively serialize Arrayables
baseRouteKey()  : string
Get the route key base for the page model.
compile()  : string
Compile the page into static HTML.
data()  : FrontMatter|mixed
Get a value from the computed page data, or fallback to the page's front matter, then to the default value.
fileExtension()  : string
Get the file extension of the source files for the page type.
files()  : array<string|int, string>
Get an array of all the source file identifiers for the model.
get()  : static
Get a page instance from the Kernel's page index by its identifier.
getBladeView()  : string
Get the Blade template/view key for the page.
getCanonicalUrl()  : string|null
getIdentifier()  : string
Get the page model's identifier property.
getLatestPosts()  : PageCollection<string|int, MarkdownPost>
getLink()  : string
Format the page instance to a URL path, with support for pretty URLs if enabled.
getOutputPath()  : string
Get the path where the compiled page will be saved.
getRoute()  : Route
Get the route object for the page.
getRouteKey()  : string
Get the route key for the page.
getSourcePath()  : string
Get the path to the instance source file, relative to the project root.
has()  : bool
See if a value exists in the computed page data or the front matter.
isDiscoverable()  : bool
Returns whether the page type is discoverable through auto-discovery.
jsonSerialize()  : array<string|int, mixed>
make()  : static
Create a new page instance. Static alias for the constructor.
markdown()  : Markdown
Return the document's Markdown object.
matter()  : FrontMatter|mixed
Get the front matter object, or a value from within.
metadata()  : PageMetadataBag
Get the generated metadata for the page.
navigationMenuGroup()  : string|null
Get the group of the page in the navigation menu, if any.
navigationMenuLabel()  : string
Get the label of the page in the navigation menu.
navigationMenuPriority()  : int
Get the priority of the page in the navigation menu.
outputDirectory()  : string
Get the output subdirectory to store compiled HTML files for the page type.
outputPath()  : string
Qualify a page identifier into a target output file path, relative to the _site output directory.
parse()  : static
Parse a source file into a new page model instance.
path()  : string
Get an absolute file path to the page's source directory, or a file within it.
pathToIdentifier()  : string
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.
save()  : $this
Save the Markdown page object to disk by compiling the front matter array to YAML and writing the body to the file.
setFileExtension()  : void
Set the file extension for the page type.
setOutputDirectory()  : void
Set the source directory for the page type.
setSourceDirectory()  : void
Set the output directory for the page type.
showInNavigation()  : bool
Can the page be shown in the navigation menu?
sourceDirectory()  : string
Get the directory where source files are stored for the page type.
sourcePath()  : string
Qualify a page identifier into file path to the source file, relative to the project root.
title()  : string
Get the page title to display in HTML tags like `<title>` and `<meta>` tags.
toArray()  : array<string|int, mixed>
Get the instance as an array.
toCoreDataObject()  : CoreDataObject
toJson()  : string
assignFactoryData()  : void
constructFactoryData()  : void
constructMetadata()  : void

Properties

$identifier read-only

public string $identifier

$outputDirectory

public static string $outputDirectory = 'posts'

$routeKey read-only

public string $routeKey

$sourceDirectory

public static string $sourceDirectory = '_posts'

$template

public static string $template = 'hyde::layouts/post'

Methods

__construct()

Construct a new page instance.

public __construct([string $identifier = '' ][, FrontMatter|array<string|int, mixed> $matter = [] ][, Markdown|string $markdown = '' ]) : mixed
Parameters
$identifier : string = ''
$matter : FrontMatter|array<string|int, mixed> = []
$markdown : Markdown|string = ''
Tags
inheritDoc

arraySerialize()

Recursively serialize Arrayables

public arraySerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

baseRouteKey()

Get the route key base for the page model.

public static baseRouteKey() : string

This is the same value as the output directory.

Return values
string

compile()

Compile the page into static HTML.

public compile() : string
Tags
inheritDoc
Return values
string

The compiled HTML for the page.

data()

Get a value from the computed page data, or fallback to the page's front matter, then to the default value.

public data([string $key = null ][, mixed $default = null ]) : FrontMatter|mixed
Parameters
$key : string = null
$default : mixed = null
Return values
FrontMatter|mixed

fileExtension()

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

public static fileExtension() : string
Return values
string

files()

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

public static files() : array<string|int, string>

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

Return values
array<string|int, string>

get()

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

public static get(string $identifier) : static
Parameters
$identifier : string
Tags
throws
FileNotFoundException

If the page does not exist.

Return values
static

getBladeView()

Get the Blade template/view key for the page.

public getBladeView() : string
Return values
string

getCanonicalUrl()

public getCanonicalUrl() : string|null
Return values
string|null

getIdentifier()

Get the page model's identifier property.

public getIdentifier() : string

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'.

Return values
string

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

public getLink() : string

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

Return values
string

getOutputPath()

Get the path where the compiled page will be saved.

public getOutputPath() : string
Return values
string

Path relative to the site output directory.

getRoute()

Get the route object for the page.

public getRoute() : Route
Return values
Route

getRouteKey()

Get the route key for the page.

public getRouteKey() : string

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.

Return values
string

getSourcePath()

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

public getSourcePath() : string
Return values
string

has()

See if a value exists in the computed page data or the front matter.

public has(string $key) : bool
Parameters
$key : string
Return values
bool

isDiscoverable()

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

public static isDiscoverable() : bool
Return values
bool

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

make()

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

public static make([string $identifier = '' ][, FrontMatter|array<string|int, mixed> $matter = [] ][, Markdown|string $markdown = '' ]) : static
Parameters
$identifier : string = ''
$matter : FrontMatter|array<string|int, mixed> = []
$markdown : Markdown|string = ''
Tags
inheritDoc
Return values
static

matter()

Get the front matter object, or a value from within.

public matter([string $key = null ][, mixed $default = null ]) : FrontMatter|mixed
Parameters
$key : string = null
$default : mixed = null
Return values
FrontMatter|mixed

navigationMenuGroup()

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

public navigationMenuGroup() : string|null
Return values
string|null

navigationMenuLabel()

Get the label of the page in the navigation menu.

public navigationMenuLabel() : string
Return values
string

navigationMenuPriority()

Get the priority of the page in the navigation menu.

public navigationMenuPriority() : int
Return values
int

outputDirectory()

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

public static outputDirectory() : string
Return values
string

outputPath()

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

public static outputPath(string $identifier) : string
Parameters
$identifier : string
Return values
string

parse()

Parse a source file into a new page model instance.

public static parse(string $identifier) : static
Parameters
$identifier : string

The identifier of the page to parse.

Tags
throws
FileNotFoundException

If the file does not exist.

Return values
static

New page model instance for the parsed source file.

path()

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

public static path([string $path = '' ]) : string
Parameters
$path : string = ''
Return values
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.

public static pathToIdentifier(string $path) : string
Parameters
$path : string

Example: index.blade.php

Return values
string

Example: index

save()

Save the Markdown page object to disk by compiling the front matter array to YAML and writing the body to the file.

public save() : $this
Return values
$this

setFileExtension()

Set the file extension for the page type.

public static setFileExtension(string $fileExtension) : void
Parameters
$fileExtension : string

setOutputDirectory()

Set the source directory for the page type.

public static setOutputDirectory(string $outputDirectory) : void
Parameters
$outputDirectory : string

setSourceDirectory()

Set the output directory for the page type.

public static setSourceDirectory(string $sourceDirectory) : void
Parameters
$sourceDirectory : string

showInNavigation()

Can the page be shown in the navigation menu?

public showInNavigation() : bool
Return values
bool

sourceDirectory()

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

public static sourceDirectory() : string
Return values
string

sourcePath()

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

public static sourcePath(string $identifier) : string
Parameters
$identifier : string
Return values
string

title()

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

public title() : string
Return values
string

toArray()

Get the instance as an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toJson()

public toJson([int $options = 0 ]) : string
Parameters
$options : int = 0
Return values
string

constructFactoryData()

protected constructFactoryData() : void

constructMetadata()

protected constructMetadata() : void

        
On this page

Search results