Skip to content

Commit

Permalink
Revert "Add canonical url and alternate links for each language avail…
Browse files Browse the repository at this point in the history
…able"

This reverts commit 3159cae.
  • Loading branch information
cgiupponi committed Aug 1, 2018
1 parent 3159cae commit e46f790
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
41 changes: 7 additions & 34 deletions Modules/Page/Http/Controllers/PublicController.php
Expand Up @@ -19,16 +19,17 @@ class PublicController extends BasePublicController
*/
private $app;

private $disabledPage = false;

public function __construct(PageRepository $page, Application $app)
{
parent::__construct();
$this->page = $page;
$this->app = $app;
$this->app = $app;
}

/**
* @param $slug
*
* @return \Illuminate\View\View
*/
public function uri($slug)
Expand All @@ -45,9 +46,7 @@ public function uri($slug)

$template = $this->getTemplateForPage($page);

$alternate = $this->getAlternateMetaData($page);

return view($template, compact('page', 'alternate'));
return view($template, compact('page'));
}

/**
Expand All @@ -61,17 +60,13 @@ public function homepage()

$template = $this->getTemplateForPage($page);

$alternate = $this->getAlternateMetaData($page);

return view($template, compact('page', 'alternate'));
return view($template, compact('page'));
}

/**
* Find a page for the given slug.
* The slug can be a 'composed' slug via the Menu
*
* @param string $slug
*
* @return Page
*/
private function findPageForSlug($slug)
Expand All @@ -88,9 +83,7 @@ private function findPageForSlug($slug)
/**
* Return the template for the given page
* or the default template if none found
*
* @param $page
*
* @return string
*/
private function getTemplateForPage($page)
Expand All @@ -99,33 +92,13 @@ private function getTemplateForPage($page)
}

/**
* Throw a 404 error page if the given page is not found
*
* Throw a 404 error page if the given page is not found or draft
* @param $page
*/
private function throw404IfNotFound($page)
{
if (is_null($page)) {
if (null === $page || $page->status === $this->disabledPage) {
$this->app->abort('404');
}
}

/**
* Create a key=>value array for alternate links
*
* @param $page
*
* @return array
*/
private function getAlternateMetaData($page)
{
$translations = $page->getTranslationsArray();

$alternate = [];
foreach ($translations as $locale => $data) {
$alternate[$locale] = $data['slug'];
}

return $alternate;
}
}
12 changes: 5 additions & 7 deletions Themes/Flatly/views/layouts/master.blade.php
Expand Up @@ -3,14 +3,12 @@
<head lang="{{ LaravelLocalization::setLocale() }}">
<meta charset="UTF-8">
@section('meta')
<meta name="description" content="@setting('core::site-description')"/>
<meta name="description" content="@setting('core::site-description')" />
@show
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@section('title')@setting('core::site-name')@show</title>
@foreach($alternate as $alternateLocale=>$alternateSlug)
<link rel="alternate" hreflang="{{$alternateLocale}}" href="{{url($alternateLocale.'/'.$alternateSlug)}}">
@endforeach
<link rel="canonical" href="{{url()->current()}}" />
<title>
@section('title')@setting('core::site-name')@show
</title>
<link rel="shortcut icon" href="{{ Theme::url('favicon.ico') }}">

{!! Theme::style('css/main.css') !!}
Expand All @@ -32,7 +30,7 @@
@yield('scripts')

<?php if (Setting::has('core::analytics-script')): ?>
{!! Setting::get('core::analytics-script') !!}
{!! Setting::get('core::analytics-script') !!}
<?php endif; ?>
@stack('js-stack')
</body>
Expand Down

0 comments on commit e46f790

Please sign in to comment.