Skip to content

Commit

Permalink
Merge pull request #1506 from hydephp/improve-semantic-documentation-…
Browse files Browse the repository at this point in the history
…article-view

Improve the semantic documentation article Blade view
  • Loading branch information
caendesilva authored Dec 23, 2023
2 parents 8d24f57 + 2f07b97 commit a26c7da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
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

0 comments on commit a26c7da

Please sign in to comment.