Skip to content

Commit

Permalink
Merge pull request #249 from robindirksen1/canonicals
Browse files Browse the repository at this point in the history
Add canonical html tag to the views
  • Loading branch information
Cannonb4ll authored Nov 16, 2023
2 parents 5d7d440 + b6d6e05 commit 35cdb5a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function show($projectId, $itemId = null)

if (!$itemId) {
$item = Item::query()->visibleForCurrentUser()->where('slug', $projectId)->firstOrFail();

if ($item->project) {
// Looks like this item is added to the project, let's redirect to the correct view for the item.
return redirect()->to($item->view_url);
}
} else {
$project = Project::query()->visibleForCurrentUser()->where('slug', $projectId)->firstOrFail();

Expand Down
1 change: 1 addition & 0 deletions resources/views/board.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@section('title', $project->title . ' - ' . $board->title)@show
@section('image', $board->getOgImage($board->description, 'Roadmap - Board'))@show
@section('description', $board->description)@show
@section('canonical', route('projects.boards.show', [$project, $board]))@show

<x-app :breadcrumbs="[
['title' => $project->title, 'url' => route('projects.show', $project)],
Expand Down
1 change: 1 addition & 0 deletions resources/views/changelog.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@section('title', 'Changelog')@show
@section('image', App\Services\OgImageGenerator::make('View changelog')->withSubject('Changelog')->withFilename('changelog.jpg')->generate()->getPublicUrl())
@section('description', 'View changelog for ' . config('app.name'))
@section('canonical', request()->routeIs('changelog.show') ? route('changelog.show', $changelogs->first()) : route('changelog'))@show

<x-app :breadcrumbs="collect([
['title' => 'Changelog', 'url' => route('changelog')],
Expand Down
1 change: 1 addition & 0 deletions resources/views/edit-item.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@section('title', 'Edit ' . $item->title)
@section('image', $item->getOgImage('"' . $item->excerpt .'"', 'Roadmap - Item'))
@section('description', $item->excerpt)
@section('canonical', route('items.edit', $item))

<x-app :breadcrumbs="[
['title' => 'Dashboard', 'url' => route('home')],
Expand Down
1 change: 1 addition & 0 deletions resources/views/item.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@section('title', $item->title)
@section('image', $item->getOgImage('"' . $item->excerpt .'"', 'Roadmap - Item'))
@section('description', $item->excerpt)
@section('canonical', $item->view_url)

<x-app :breadcrumbs="$project ? [
['title' => $project->title, 'url' => route('projects.show', $project)],
Expand Down
4 changes: 4 additions & 0 deletions resources/views/partials/meta.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@

<link rel="sitemap" type="application/xml" href="{{ asset('sitemap.xml') }}">

@hasSection('canonical')
<link rel="canonical" href="@yield('canonical')">
@endif

@yield('additional_meta')
1 change: 1 addition & 0 deletions resources/views/project.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@section('title', $project->title)@show
@section('image', $project->getOgImage($project->description, 'Roadmap - Project'))@show
@section('description', $project->description)@show
@section('canonical', route('projects.show', $project))@show

<x-app :breadcrumbs="[
['title' => $project->title, 'url' => route('projects.show', $project)]
Expand Down
2 changes: 2 additions & 0 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@section('canonical', route('home'))@show

<x-app>
@if($text = app(\App\Settings\GeneralSettings::class)->welcome_text)
<div class="prose mb-4">{!! $text !!}</div>
Expand Down

0 comments on commit 35cdb5a

Please sign in to comment.