Skip to content

Commit

Permalink
Merge pull request #60 from tightenco/feature/meta-and-og-preview
Browse files Browse the repository at this point in the history
Add meta and OG
  • Loading branch information
mattstauffer committed Jul 11, 2015
2 parents 202c6dc + 57321b8 commit ec17311
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Gists/Gistlog.php
Expand Up @@ -91,4 +91,10 @@ public function isSecret()
{
return ! $this->isPublic();
}

public function getPreview()
{
$body = strip_tags($this->renderHtml());
return substr($body, 0, strpos($body, ' ', 200));
}
}
13 changes: 13 additions & 0 deletions resources/views/gistlogs/show.blade.php
Expand Up @@ -50,3 +50,16 @@
});
</script>
@endsection

@section('meta')
<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="{{ $gistlog->title }}">
<meta itemprop="description" content="{{ $gistlog->getPreview() }}">

<!-- Open Graph data -->
<meta property="og:title" content="{{ $gistlog->title }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ Request::url() }}">
<meta property="og:description" content="{{ $gistlog->getPreview() }}">
<meta property="og:site_name" content="Gistlog">
@endsection
2 changes: 2 additions & 0 deletions resources/views/layouts/app.blade.php
Expand Up @@ -6,6 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}Gistlog</title>

@yield ('meta')

<link href="/css/app.css" rel="stylesheet">
@if (isset($gistlog) && $gistlog->isSecret())
<meta name="robots" content="noindex, nofollow">
Expand Down

0 comments on commit ec17311

Please sign in to comment.