Skip to content

Commit

Permalink
Basic open graph metadata tags, see #45
Browse files Browse the repository at this point in the history
  • Loading branch information
LogicAndTrick committed Apr 7, 2021
1 parent 33108b8 commit eb29a6e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 2 deletions.
21 changes: 21 additions & 0 deletions resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>{{ isset($page_title) && !!$page_title ? $page_title . ' - ' : '' }}TWHL: Half-Life and Source Mapping Tutorials and Resources</title>

@if (isset($meta_description) && strlen($meta_description) > 0)
<?php $meta_description = str_replace("\n", ' ', substr($meta_description, 0, 300)) . (strlen($meta_description) > 300 ? '...' : ''); ?>
<meta name="description" property="og:description" content="{{$meta_description}}">
@else
<meta name="description" property="og:description" content="View this page on TWHL">
@endif
<meta property="og:type" content="website">
@if (isset($meta_title) && strlen($meta_title) > 0)
<meta property="og:title" content="{{$meta_title}}">
@else
<meta property="og:title" content="{{$page_title}}">
@endif
@if (isset($meta_images) && count($meta_images) > 0)
@foreach ($meta_images as $img)
<meta property="og:image" content="{{asset($img)}}">
@endforeach
@else
<meta property="og:image" content="{{asset('images/twhl-logo.png')}}">
@endif
<meta property="og:url" content="{{Request::url()}}">

<link href="{{ mix('/css/app.css') }}?sl" rel="stylesheet">
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />

Expand Down
4 changes: 4 additions & 0 deletions resources/views/competitions/competition/brief.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@title('Competition: '.$comp->name)
@extends('app')

<?php
$meta_description = $comp->brief_text;
?>

@section('content')
<h1>
Competition: {{ $comp->name }}
Expand Down
4 changes: 4 additions & 0 deletions resources/views/forums/thread/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@title($thread->title)
@extends('app')

<?php
if ($posts->onFirstPage() && $posts->count() > 0) $meta_description = $posts[0]->content_text;
?>

@section('content')

<h1>
Expand Down
5 changes: 5 additions & 0 deletions resources/views/journal/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@title('Journal: '.$journal->getTitle().' by '.$journal->user->name)
@extends('app')

<?php
$meta_title = $journal->getTitle().' by '.$journal->user->name;
$meta_description = $journal->content_text;
?>

@section('content')
<h1>
{{ $journal->getTitle() }}
Expand Down
5 changes: 5 additions & 0 deletions resources/views/news/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@title('News post: '.$news->title)
@extends('app')

<?php
$meta_title = $news->title;
$meta_description = $news->content_text;
?>

@section('content')
<h1>
{{ $news->title }}
Expand Down
4 changes: 4 additions & 0 deletions resources/views/polls/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@title('Poll: '.$poll->title)
@extends('app')

<?php
$meta_description = $poll->content_text;
?>

@section('content')
<h1>
{{ $poll->title }}
Expand Down
8 changes: 8 additions & 0 deletions resources/views/vault/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
@title($item->name)
@extends('app')

<?php
if (count($item->vault_screenshots) > 0) {
$meta_images = $item->vault_screenshots->sortBy('order_index')->map(function ($sshot) { return 'uploads/vault/'.$sshot->image_large; });
}
$meta_description = $item->content_text;
$meta_title = $item->name . ' by ' . $item->user->name;
?>

@section('content')

<h1>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/wiki/edit/page.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@title('Edit wiki page: ')
@title('Edit wiki page: ' . $revision->getNiceTitle())
@extends('app')

@section('content')
Expand Down
5 changes: 4 additions & 1 deletion resources/views/wiki/view/object.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@extends('app')
<?php
if ($revision) $meta_description = $revision->content_text;
?>

@section('content')
@include('wiki.nav', ['revision' => $revision, 'cat_name' => $cat_name])
@if ($cat_name !== null)
@title('Wiki: Category: ' . $cat_name)
@title('Wiki: Category: ' . str_replace('_', ' ', str_replace('+', ' > ', $cat_name)))
@include('wiki.view.category', ['object' => $object, 'revision' => $revision, 'cat_name' => $cat_name, 'cat_pages' => $cat_pages])
@elseif ($object == null)
@title('Page Not Found')
Expand Down

0 comments on commit eb29a6e

Please sign in to comment.