diff --git a/src/Directives/SeoProDirective.php b/src/Directives/SeoProDirective.php index 71fd86e5..c76873e0 100644 --- a/src/Directives/SeoProDirective.php +++ b/src/Directives/SeoProDirective.php @@ -16,7 +16,10 @@ public function renderTag($tag, $context) ); } - return $this->setContext($context)->$tag(); + return $this + ->setContext($context) + ->setParameters([]) + ->$tag(); } protected function isMissingContext($context) diff --git a/src/Tags/SeoProTags.php b/src/Tags/SeoProTags.php index 0bad613e..3233f224 100755 --- a/src/Tags/SeoProTags.php +++ b/src/Tags/SeoProTags.php @@ -49,7 +49,7 @@ public function metaData() $metaData['is_twitter_glide_enabled'] = $this->isGlidePresetEnabled('seo_pro_twitter'); $metaData['is_og_glide_enabled'] = $this->isGlidePresetEnabled('seo_pro_og'); - return $metaData; + return $this->aliasedResult($metaData); } /** diff --git a/tests/Fixtures/site/content/collections/pages/about.md b/tests/Fixtures/site/content/collections/pages/about.md index 2abaec00..a1d0f441 100644 --- a/tests/Fixtures/site/content/collections/pages/about.md +++ b/tests/Fixtures/site/content/collections/pages/about.md @@ -1,8 +1,9 @@ --- title: About +subtitle: The Best About Page updated_by: 96300192-873c-4615-b992-157508a8d7c5 updated_at: 1579284102 template: page id: 62136fa2-9e5c-4c38-a894-a2753f02f5ff --- -I'm just a kid living in the 90's, writing articles in his secret public journal wonder if someday, somewhere in the future, they will be read by someone. \ No newline at end of file +I'm just a kid living in the 90's, writing articles in his secret public journal wonder if someday, somewhere in the future, they will be read by someone. diff --git a/tests/MetaTagTest.php b/tests/MetaTagTest.php index 30828a1a..fe5906a0 100644 --- a/tests/MetaTagTest.php +++ b/tests/MetaTagTest.php @@ -773,6 +773,54 @@ public function it_hydrates_cascade_on_custom_routes_using_blade_directive($view $this->assertStringContainsStringIgnoringLineEndings('Custom Route Entry Title | Site Name', $content); } + /** @test */ + public function it_can_loop_over_meta_data() + { + $this->withoutExceptionHandling(); + $this->prepareViews('antlers'); + $this->files->put(resource_path('views-seo-pro/layout.antlers.html'), <<<'EOT' +{{ seo_pro:meta_data }} +

{{ title }}

+

{{ description }}

+

{{ canonical_url }}

+{{ /seo_pro:meta_data }} +EOT); + + $content = $this->get('/the-view')->content(); + $this->assertStringContainsStringIgnoringLineEndings('

The View

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

A wonderful view!

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

http://cool-runnings.com/the-view

', $content); + } + + /** @test */ + public function it_can_loop_over_aliased_meta_data() + { + $this->withoutExceptionHandling(); + + $this + ->prepareViews('antlers') + ->setSeoOnCollection(Collection::find('pages'), [ + 'title' => '@seo:subtitle', + ]); + + $this->files->put(resource_path('views-seo-pro/layout.antlers.html'), <<<'EOT' +

{{ title }}

+{{ seo_pro:meta_data as="foo" }} +

{{ title }}

+

{{ foo:title }}

+

{{ foo:canonical_url }}

+

{{ canonical_url }}

+{{ /seo_pro:meta_data }} +EOT); + + $content = $this->get('/about')->content(); + $this->assertStringContainsStringIgnoringLineEndings('

About

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

About

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

The Best About Page

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

http://cool-runnings.com/about

', $content); + $this->assertStringContainsStringIgnoringLineEndings('

', $content); + } + protected function setCustomGlidePresetDimensions($app) { $app->config->set('statamic.seo-pro.assets', [