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 documentation heading permalinks feature #659

Merged
merged 1 commit into from
Jul 8, 2024
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
2 changes: 1 addition & 1 deletion src/Framework/Services/AssetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class AssetService
{
/** @var string The default HydeFront SemVer tag to load. This constant is set to match the styles used for the installed framework version. */
final public const HYDEFRONT_VERSION = 'v3.3';
final public const HYDEFRONT_VERSION = 'v3.4';

/** @var string The default HydeFront CDN path pattern. The Blade-style placeholders are replaced with the proper values. */
final public const HYDEFRONT_CDN_URL = 'https://cdn.jsdelivr.net/npm/hydefront@{{ $version }}/dist/{{ $file }}';
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/Services/MarkdownService.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ protected function configurePermalinksExtension(): void
'heading_permalink' => [
'id_prefix' => '',
'fragment_prefix' => '',
'symbol' => '#',
'symbol' => '',
'insert' => 'after',
'min_heading_level' => 2,
'aria_hidden' => false,
],
], $this->config);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/MarkdownServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function testServiceCanParseMarkdownToHtmlWithPermalinks()

$this->assertIsString($html);
$this->assertSame(
'<h2>Hello World!<a id="hello-world" href="#hello-world" class="heading-permalink" aria-hidden="true" '.
'title="Permalink">#</a></h2>'."\n",
'<h2>Hello World!<a id="hello-world" href="#hello-world" class="heading-permalink" '.
'title="Permalink"></a></h2>'."\n",
$html
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/StaticSiteBuilderDocumentationModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testPageContainsExpectedContent()
{
$this->inspectHtml([
'Adventures in Wonderland',
'<h2>CHAPTER I. DOWN THE RABBIT-HOLE.<a id="chapter-i-down-the-rabbit-hole" href="#chapter-i-down-the-rabbit-hole" class="heading-permalink" aria-hidden="true" title="Permalink">#</a></h2>',
'<h2>CHAPTER I. DOWN THE RABBIT-HOLE.<a id="chapter-i-down-the-rabbit-hole" href="#chapter-i-down-the-rabbit-hole" class="heading-permalink" title="Permalink"></a></h2>',
'<p>So she was considering in her own mind, as well as she could',
]);
}
Expand All @@ -55,7 +55,7 @@ public function testCanCompilePageToRootOutputDirectory()

$this->inspectHtml([
'Adventures in Wonderland',
'<h2>CHAPTER I. DOWN THE RABBIT-HOLE.<a id="chapter-i-down-the-rabbit-hole" href="#chapter-i-down-the-rabbit-hole" class="heading-permalink" aria-hidden="true" title="Permalink">#</a></h2>',
'<h2>CHAPTER I. DOWN THE RABBIT-HOLE.<a id="chapter-i-down-the-rabbit-hole" href="#chapter-i-down-the-rabbit-hole" class="heading-permalink" title="Permalink"></a></h2>',
'<p>So she was considering in her own mind, as well as she could',
], '_site/test-page.html');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/AssetServiceUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp(): void

public function testVersionStringConstant()
{
$this->assertSame('v3.3', AssetService::HYDEFRONT_VERSION);
$this->assertSame('v3.4', AssetService::HYDEFRONT_VERSION);
}

public function testServiceHasVersionString()
Expand Down Expand Up @@ -56,7 +56,7 @@ public function testCanSetCustomCdnUrlInConfig()
public function testCanUseCustomCdnUrlWithVersion()
{
self::mockConfig(['hyde.hydefront_url' => '{{ $version }}']);
$this->assertSame('v3.3', (new AssetService())->cdnLink(''));
$this->assertSame('v3.4', (new AssetService())->cdnLink(''));
}

public function testCanUseCustomCdnUrlWithFile()
Expand All @@ -68,7 +68,7 @@ public function testCanUseCustomCdnUrlWithFile()
public function testCanUseCustomCdnUrlWithVersionAndFile()
{
self::mockConfig(['hyde.hydefront_url' => '{{ $version }}/{{ $file }}']);
$this->assertSame('v3.3/styles.css', (new AssetService())->cdnLink('styles.css'));
$this->assertSame('v3.4/styles.css', (new AssetService())->cdnLink('styles.css'));
}

public function testCanUseCustomCdnUrlWithCustomVersion()
Expand All @@ -83,7 +83,7 @@ public function testCanUseCustomCdnUrlWithCustomVersion()
public function testCdnLinkHelper()
{
$this->assertSame(
'https://cdn.jsdelivr.net/npm/hydefront@v3.3/dist/styles.css',
'https://cdn.jsdelivr.net/npm/hydefront@v3.4/dist/styles.css',
(new AssetService())->cdnLink('styles.css')
);
}
Expand Down
Loading