Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This serves two purposes:
- Added support for setting custom navigation items in the YAML configuration in https://github.com/hydephp/develop/pull/1818
- Added support for setting extra attributes for navigation items in https://github.com/hydephp/develop/pull/1824
- Introduced a new navigation config builder class to simplify navigation configuration in https://github.com/hydephp/develop/pull/1827
- You can now add custom posts to the blog post feed component when including it directly in https://github.com/hydephp/develop/pull/1893

### Changed
- **Breaking:** The internals of the navigation system has been rewritten into a new Navigation API. This change is breaking for custom navigation implementations. For more information, see below.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ol itemscope itemtype="https://schema.org/ItemList">
@foreach(MarkdownPost::getLatestPosts()->values() as $index => $post)
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="mt-4 mb-8">
<meta itemprop="position" content="{{ $index + 1 }}">
@include('hyde::components.article-excerpt')
</li>
@endforeach
@foreach($posts ?? MarkdownPost::getLatestPosts() as $post)
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="mt-4 mb-8">
<meta itemprop="position" content="{{ $loop->iteration }}">
@include('hyde::components.article-excerpt')
</li>
@endforeach
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

namespace Hyde\Framework\Testing\Unit\Views;

use Hyde\Hyde;
use Hyde\Testing\TestCase;
use Hyde\Pages\MarkdownPost;
use Hyde\Testing\TestsBladeViews;

/**
* @coversNothing Test to ensure the blog post feed component can be rendered
*/
class BlogPostFeedComponentViewTest extends TestCase
{
use TestsBladeViews;

public function testPostFeedWithoutPosts()
{
$view = $this->view(view('hyde::components.blog-post-feed'));

$view->assertSeeHtml('<ol itemscope itemtype="https://schema.org/ItemList">')
->assertDontSee('<li')
->assertDontSee('<article')
->assertSeeHtml('</ol>');
}

public function testPostFeedWithSinglePost()
{
Hyde::pages()->add(new MarkdownPost('hello-world', ['author' => 'mr_hyde'], 'Hello World!'));

$view = $this->view(view('hyde::components.blog-post-feed'));

$view->assertSeeHtml('<ol itemscope itemtype="https://schema.org/ItemList">')
->assertSeeHtml('<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"')
->assertSeeHtml('<meta itemprop="position" content="1">')
->assertSeeHtml('<article itemprop="item" itemscope itemtype="https://schema.org/BlogPosting">')
->assertSeeHtml('<meta itemprop="identifier" content="hello-world">')
->assertSeeHtml('<a href="posts/hello-world.html"')
->assertSeeHtml('<h2 itemprop="headline"')
->assertSee('Hello World')
->assertSeeHtml('<span itemprop="author" itemscope itemtype="https://schema.org/Person">')
->assertSee('Mr. Hyde')
->assertSeeHtml('<p itemprop="description"')
->assertSee('Hello World!')
->assertSeeHtml('<a href="posts/hello-world.html"')
->assertSee('Read post')
->assertSeeHtml('</article>')
->assertSeeHtml('</li>')
->assertSeeHtml('</ol>');
}

public function testPostFeedWithMultiplePosts()
{
Hyde::pages()->add(new MarkdownPost('hello-world', ['author' => 'mr_hyde'], 'Hello World!'));
Hyde::pages()->add(new MarkdownPost('second-post', ['author' => 'jane_doe'], 'Another post content'));

$view = $this->view(view('hyde::components.blog-post-feed'));

$view->assertSeeHtml('<ol itemscope itemtype="https://schema.org/ItemList">')
->assertSeeHtml('<meta itemprop="position" content="1">')
->assertSeeHtml('<meta itemprop="position" content="2">')
->assertSee('Hello World')
->assertSee('Mr. Hyde')
->assertSee('Another post content')
->assertSee('Jane Doe')
->assertSeeHtml('</ol>');
}

public function testPostFeedWithCustomPosts()
{
Hyde::pages()->add(new MarkdownPost('global', ['author' => 'default'], 'Ignored post content'));

$customPosts = [
new MarkdownPost('hello-world', ['author' => 'mr_hyde'], 'Hello World!'),
new MarkdownPost('second-post', ['author' => 'jane_doe'], 'Another post content'),
];

$view = $this->view(view('hyde::components.blog-post-feed', [
'posts' => $customPosts,
]));

$view->assertSeeHtml('<ol itemscope itemtype="https://schema.org/ItemList">')
->assertDontSee('Ignored post content')
->assertSee('Hello World')
->assertSee('Mr. Hyde')
->assertSee('Another post content')
->assertSee('Jane Doe')
->assertSeeHtml('</ol>');
}
}