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

[FEATURE] add option to hide the sitetitle #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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