Skip to content

Commit

Permalink
Add class="notranslate" to meta tag (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterangelov authored and vinicius73 committed Sep 5, 2019
1 parent 3b3ac64 commit c98c438
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SEOTools/SEOMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function generate($minify = false)
$html = [];

if ($title) {
$html[] = "<title>$title</title>";
$html[] = Arr::get($this->config, 'add_notranslate_class', false) ? "<title class=\"notranslate\">$title</title>" : "<title>$title</title>";
}

if ($description) {
Expand Down
2 changes: 2 additions & 0 deletions src/resources/config/seotools.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
'pinterest' => null,
'yandex' => null,
],

'add_notranslate_class' => false,
],
'opengraph' => [
/*
Expand Down
16 changes: 16 additions & 0 deletions tests/SEOTools/SEOMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,20 @@ public function test_utf8()
$this->assertEquals($description, $this->seoMeta->getDescription());
$this->setRightAssertion($fullHeader);
}

public function test_it_can_add_notranslate_class_to_title()
{
$this->seoMeta = new SEOMeta(new \Illuminate\Config\Repository([
'add_notranslate_class' => true,
'defaults' => [
'title' => 'It\'s Over 9000!',
'description' => 'For those who helped create the Genki Dama',
],
]));

$expected = "<title class=\"notranslate\">It's Over 9000!</title>";
$expected .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";

$this->setRightAssertion($expected);
}
}

0 comments on commit c98c438

Please sign in to comment.