Skip to content

Commit

Permalink
[FEATURE] add option to hide the sitetitle
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibome committed Oct 23, 2022
1 parent 9c3da53 commit d68a08c
Show file tree
Hide file tree
Showing 7 changed files with 4,988 additions and 4,907 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ The separator between page title and site title can be customized like this:

The default value is ` | `.

### Hide `site title`

To not output the site title can be customized like this:

```
'diesdasdigital.meta-knight' => [
'hideSiteTitle' => true,
],
```

### Canonical URLs

Meta Knight gives you control over how the auto-generated canonical URLs for your pages are rendered. By default canonical URLs do not include the `www.` subdomain. If you wish the canonical URLs to include `www.` please set the following option in config.php:
Expand Down
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
'options' => [
'siteTitleAfterPageTitle' => true,
'siteTitleAsHomePageTitle' => false,
'canonicalURLIncludesWWW' => false
'canonicalURLIncludesWWW' => false,
'hideSiteTitle' => false,
],
'pageMethods' => [
'canonicalUrl' => function () {
if (option('diesdasdigital.meta-knight.canonicalURLIncludesWWW') === false) {
if (option('diesdasdigital.meta-knight.canonicalURLIncludesWWW') === false) {
return preg_replace(array('/http:/', '/www\./'), array('https:',''), $this->url());
} else {
return preg_replace('/http(s)?:\/\/(www.)?/', 'https://www.', $this->url());
Expand Down
3 changes: 3 additions & 0 deletions sections/google_search_preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
'separator' => function () {
return option('diesdasdigital.meta-knight.separator', ' - ');
},
'hideSiteTitle' => function () {
return option('diesdasdigital.meta-knight.hideSiteTitle', false);
},
]
];
4 changes: 3 additions & 1 deletion snippets/meta_information.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
'crop' => true
];

if(option('diesdasdigital.meta-knight.siteTitleAsHomePageTitle', false) && $page->isHomePage()) {
if(option('diesdasdigital.meta-knight.hideSiteTitle', false)) {
$full_title = $page->meta_title()->or($page->title());
} elseif(option('diesdasdigital.meta-knight.siteTitleAsHomePageTitle', false) && $page->isHomePage()) {
$full_title = $site->meta_title()->or($site->title());
} elseif(option('diesdasdigital.meta-knight.pageTitleAsHomePageTitle', false) && $page->isHomePage()) {
$full_title = $page->meta_title()->or($page->title());
Expand Down
9 changes: 8 additions & 1 deletion src/components/sections/google_search_preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
this.siteTitleAfterPageTitle = response.siteTitleAfterPageTitle;
this.siteTitleAsHomePageTitle = response.siteTitleAsHomePageTitle;
this.separator = response.separator;
this.hideSiteTitle = response.hideSiteTitle;
});
this.$api.site.get().then((response) => {
this.site_title = response.title;
Expand All @@ -60,7 +61,13 @@ export default {
} else if (this.uid == "home" && this.siteTitleAsHomePageTitle) {
meta_title = this.site_meta_title || this.site_title;
} else {
if (this.siteTitleAfterPageTitle == true) {
if (this.hideSiteTitle === true) {
if (meta_title == "") {
meta_title = this.page_title;
} else {
meta_title = meta_title;
}
} else if (this.siteTitleAfterPageTitle == true) {
if (meta_title == "") {
meta_title = this.page_title + this.separator + this.site_title;
} else {
Expand Down
Loading

0 comments on commit d68a08c

Please sign in to comment.