BlogPostDataFactory
extends PageDataFactory
in package
implements
BlogPostSchema
Streamlines the data construction specific to a blog post.
Simply pass along the data the class needs to run, then access the data using the toArray() method.
All data can be set using front matter in the page source file. If no front matter is set for the given key, this class will attempt to generate and discover the values based on the page and the project's configuration.
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.
Constants
- SCHEMA = \Hyde\Markdown\Contracts\FrontMatter\BlogPostSchema::BLOG_POST_SCHEMA
- The front matter properties supported by this factory.
Properties
- $author : PostAuthor|null
- $category : string|null
- $date : DateString|null
- $description : string|null
- $image : FeaturedImage|null
- $filePath : string
- $markdown : Markdown
- $matter : FrontMatter
Methods
- __construct() : mixed
- toArray() : FeaturedImage|null}
- Get the generated data as an associative array.
- getMatter() : string|null|array<string|int, mixed>
- makeAuthor() : PostAuthor|null
- makeCategory() : string|null
- makeDate() : DateString|null
- makeDescription() : string
- makeImage() : FeaturedImage|null
- makeDescriptionFromMarkdownBody() : string
Constants
SCHEMA
The front matter properties supported by this factory.
public
final array<string, string|array<string|int, mixed>>
SCHEMA
= \Hyde\Markdown\Contracts\FrontMatter\BlogPostSchema::BLOG_POST_SCHEMA
Note that this class does not add the title, as that is already added to all pages.
Properties
$author read-only
protected
PostAuthor|null
$author
$category read-only
protected
string|null
$category
$date read-only
protected
DateString|null
$date
$description read-only
protected
string|null
$description
$image read-only
protected
FeaturedImage|null
$image
$filePath read-only
private
string
$filePath
$markdown read-only
private
Markdown
$markdown
$matter read-only
private
FrontMatter
$matter
Methods
__construct()
public
__construct(CoreDataObject $pageData) : mixed
Parameters
- $pageData : CoreDataObject
toArray()
Get the generated data as an associative array.
public
toArray() : FeaturedImage|null}
Return values
FeaturedImage|null}getMatter()
protected
getMatter(string $key) : string|null|array<string|int, mixed>
Parameters
- $key : string
Return values
string|null|array<string|int, mixed>makeAuthor()
protected
makeAuthor() : PostAuthor|null
Return values
PostAuthor|nullmakeCategory()
protected
makeCategory() : string|null
Return values
string|nullmakeDate()
protected
makeDate() : DateString|null
Return values
DateString|nullmakeDescription()
protected
makeDescription() : string
Return values
stringmakeImage()
protected
makeImage() : FeaturedImage|null
Return values
FeaturedImage|nullmakeDescriptionFromMarkdownBody()
private
makeDescriptionFromMarkdownBody() : string