Skip to content

Commit

Permalink
More breadcrumb schema (#167)
Browse files Browse the repository at this point in the history
* Added breadcrumb schema for tools pages

* Added breadcrumb schema for features pages
  • Loading branch information
l-alexandrov committed May 12, 2024
1 parent f637fd7 commit 2b6a647
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 20 deletions.
36 changes: 32 additions & 4 deletions app/Http/Controllers/FeaturesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Spatie\SchemaOrg\BreadcrumbList;
use Spatie\SchemaOrg\Schema;

class FeaturesController extends Controller
{
Expand All @@ -20,7 +22,8 @@ public function index(Request $request): Factory|View|Application
'seo' => [
'seo_title' => 'Features',
'seo_description' => 'Check out our features'
]
],
'schema' => $this->generateBreadCrumbSchema()->toScript()
]);
}

Expand All @@ -35,7 +38,8 @@ public function upvote(Request $request): Factory|View|Application
'seo_title' => 'Upvote',
'seo_description' => 'Let your users give you product improvement suggestions, bringing their feedback to a next level',
'keywords' => 'upvote, product improvement, customer feedback, feedback organization, feedback voting, customer relationships, user requests, user ideas, user suggestions, support automation'
]
],
'schema' => $this->generateBreadCrumbSchema('Upvote', route('features.upvote'))->toScript()
]);
}

Expand All @@ -51,7 +55,8 @@ public function faq(Request $request): Factory|View|Application
'seo_title' => 'FAQ',
'seo_description' => 'Provide answers to all common questions',
'keywords' => 'FAQ, frequently asked questions, frequently asked questions portal, collapsible FAQ, FAQ panel, support automation'
]
],
'schema' => $this->generateBreadCrumbSchema('FAQ', route('features.faq'))->toScript()
]);
}

Expand All @@ -66,7 +71,30 @@ public function roadmap(Request $request): Factory|View|Application
'seo_title' => 'Product Roadmap',
'seo_description' => 'Show your users their opinion matters, visualizing the progress on their requests',
'keywords' => 'roadmap, product roadmap product improvement, product transparency, customer feedback, feedback organization, customer relationships, user requests, user ideas, user suggestions, product building, board, kanban'
]
],
'schema' => $this->generateBreadCrumbSchema('Roadmap', route('features.roadmap'))->toScript()
]);
}

/**
* @param string|null $featureName
* @param string|null $featureRoute
* @return BreadcrumbList
*/
private function generateBreadCrumbSchema(string $featureName = null, string $featureRoute = null): BreadcrumbList
{
$indexRoute = route('features.index');
$listElements = [
Schema::listItem()->position(1)->url($indexRoute)->name('Features')
->setProperty('item', $indexRoute)
];
if($featureName !== null){
$listElements[] = Schema::listItem()->position(2)
->url($featureRoute)->name($featureName)
->setProperty('item', $featureRoute);
}

return Schema::breadcrumbList()
->itemListElement($listElements);
}
}
64 changes: 48 additions & 16 deletions app/Http/Controllers/ToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,66 @@
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Spatie\SchemaOrg\BreadcrumbList;
use Spatie\SchemaOrg\Schema;

class ToolsController extends Controller
{
public function index(): Factory|View|Application
{
return view('theme::tools', ['seo' => [
'seo_title' => 'Free tools',
'seo_description' => 'Our free for use online tools.',
'keywords' => 'responsive images, tools, online, web, changelog, generator, free'
]]);
return view('theme::tools', [
'seo' => [
'seo_title' => 'Free tools',
'seo_description' => 'Our free for use online tools.',
'keywords' => 'responsive images, tools, online, web, changelog, generator, free'
],
'schema' => $this->generateBreadCrumbSchema()->toScript()
]);
}

public function responsiveImages(): Factory|View|Application
{
return view('theme::tools.responsive-images', ['seo' => [
'seo_title' => 'Resonsive images generator',
'seo_description' => 'Responsive images generation made easily.',
'keywords' => 'responsive images, image generator, image resonsive, image breakpoints, free, online generator, image tools, srcset, sm, xs, md, lg, 2xl, google lighthouse report'
]]);
return view('theme::tools.responsive-images', [
'seo' => [
'seo_title' => 'Resonsive images generator',
'seo_description' => 'Responsive images generation made easily.',
'keywords' => 'responsive images, image generator, image resonsive, image breakpoints, free, online generator, image tools, srcset, sm, xs, md, lg, 2xl, google lighthouse report'
],
'schema' => $this->generateBreadCrumbSchema('Responsive images generator', route('tools.responsive-images'))->toScript()
]);
}

public function keepALog(): Factory|\Illuminate\Foundation\Application|View|Application
{
return view('theme::tools.keep-a-log', ['seo' => [
'seo_title' => 'Keep a log',
'seo_description' => 'Keep a log of what has been changed in your product.',
'keywords' => 'keep a log, changelog, changelog generator, free, product tools, product management, what is new, added, removed, version, changed, versioning, markdown, md'
]]);
return view('theme::tools.keep-a-log', [
'seo' => [
'seo_title' => 'Keep a log',
'seo_description' => 'Keep a log of what has been changed in your product.',
'keywords' => 'keep a log, changelog, changelog generator, free, product tools, product management, what is new, added, removed, version, changed, versioning, markdown, md'
],
'schema' => $this->generateBreadCrumbSchema('Keep a log', route('tools.keep-a-log'))->toScript()
]);
}

/**
* @param string|null $toolName
* @param string|null $toolRoute
* @return BreadcrumbList
*/
private function generateBreadCrumbSchema(string $toolName = null, string $toolRoute = null): BreadcrumbList
{
$indexRoute = route('tools.index');
$listElements = [
Schema::listItem()->position(1)->url($indexRoute)->name('Tools')
->setProperty('item', $indexRoute)
];
if($toolName !== null){
$listElements[] = Schema::listItem()->position(2)
->url($toolRoute)->name($toolName)
->setProperty('item', $toolRoute);
}

return Schema::breadcrumbList()
->itemListElement($listElements);
}
}

0 comments on commit 2b6a647

Please sign in to comment.