Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the semantic documentation article Blade view #1506

Merged
merged 3 commits into from
Dec 23, 2023
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
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ This serves two purposes:
- for new features.

### Changed
- for changes in existing functionality.
- Renamed local template variable `$document` to `$article` to better match the usage in https://github.com/hydephp/develop/pull/1506
- Updated semantic documentation article component to support existing variables in https://github.com/hydephp/develop/pull/1506

### Deprecated
- for soon-to-be removed features.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@php
$document = \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page);
$article ??= \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page);
@endphp

<article id="document" itemscope itemtype="https://schema.org/Article" @class([
'mx-auto lg:ml-8 max-w-3xl p-12 md:px-16 max-w-[1000px] min-h-[calc(100vh_-_4rem)]',
config('markdown.prose_classes', 'prose dark:prose-invert'),
'torchlight-enabled' => $document->hasTorchlight()])>
'torchlight-enabled' => $article->hasTorchlight()])>
@yield('content')

<header id="document-header" class="flex items-center flex-wrap justify-between prose-h1:mb-3">
{{ $document->renderHeader() }}
{{ $article->renderHeader() }}
</header>
<section id="document-main-content" itemprop="articleBody">
{{ $document->renderBody() }}
{{ $article->renderBody() }}
</section>
<footer id="document-footer" class="flex items-center flex-wrap mt-8 prose-p:my-3 justify-between text-[90%]">
{{ $document->renderFooter() }}
{{ $article->renderFooter() }}
</footer>
</article>
22 changes: 22 additions & 0 deletions packages/framework/tests/Feature/Services/HydeSmartDocsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,28 @@ public function test_the_documentation_article_view()
$this->assertStringContainsString('<p>Hello world.</p>', $rendered);
}

public function test_the_documentation_article_view_with_existing_variable()
{
$rendered = view('hyde::components.docs.documentation-article', [
'page' => $page = $this->makePage(),
'article' => new class($page) extends SemanticDocumentationArticle
{
public function __construct(DocumentationPage $page)
{
parent::__construct($page);
}

public function renderHeader(): HtmlString
{
return new HtmlString('<h1>Custom Header</h1>');
}
},
])->render();

$this->assertStringContainsString('<h1>Custom Header</h1>', $rendered);
$this->assertStringContainsString('<p>Hello world.</p>', $rendered);
}

protected function makeArticle(string $sourceFileContents = "# Foo\n\nHello world."): SemanticDocumentationArticle
{
$this->file('_docs/foo.md', $sourceFileContents);
Expand Down
Loading