Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Better links and pages and SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Aug 14, 2018
1 parent a389858 commit efd285b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Models/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Grafite\Cms\Models;

use Grafite\Cms\Models\CmsModel;
use Grafite\Cms\Models\Page;
use Grafite\Cms\Traits\Translatable;

class Link extends CmsModel
Expand All @@ -27,10 +28,19 @@ class Link extends CmsModel
'external_url',
];

public $with = [
'page'
];

public function __construct(array $attributes = [])
{
$keys = array_keys(request()->except('_method', '_token'));
$this->fillable(array_values(array_unique(array_merge($this->fillable, $keys))));
parent::__construct($attributes);
}

public function page()
{
return $this->belongsTo(Page::class);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!doctype html>

<html lang="en">
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand All @@ -12,6 +12,11 @@
<meta name="keywords" content="@yield('seoKeywords')">
<meta name="author" content="">

<meta property="og:title" content="@if (isset($page) && !is_null($page->title)) - {{ $page->title }} @endif">
<meta property="og:description" content="@yield('seoDescription')">
<meta property="og:image" content="">
<meta property="og:url" content="">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="{{ asset('css/app.css') }}">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@if ($link->external)
<li class="nav-item"><a class="nav-link" href="{{ url($link->external_url) }}">{{ $link->name }}</a></li>
@else
<li class="nav-item"><a class="nav-link" href="{{ url('p/'.\Grafite\Cms\Models\Page::find($link->page_id)->url) }}">{{ $link->name }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('p/'.$link->page->url) }}">{{ $link->name }}</a></li>
@endif
@endforeach
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@if ($link->external)
<li class="nav-item"><a class="nav-link" href="{{ url($link->external_url) }}">{{ $link->name }}</a></li>
@else
<li class="nav-item"><a class="nav-link" href="{{ url('p/'.\Grafite\Cms\Models\Page::find($link->page_id)->url) }}">{{ $link->name }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('p/'.$link->page->url) }}">{{ $link->name }}</a></li>
@endif
@endforeach

0 comments on commit efd285b

Please sign in to comment.