Skip to content

Commit

Permalink
feat: breadcrumbs with microformats
Browse files Browse the repository at this point in the history
  • Loading branch information
tbreuss committed Jul 22, 2023
1 parent dec80c5 commit aba4473
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 8 deletions.
4 changes: 4 additions & 0 deletions assets/app/dist/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4660,6 +4660,10 @@ progress {
}

.container--content {
margin-top: 1.5rem;
}

.action-site-index .container--content {
margin-top: 2.5rem;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/app/dist/main.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/app/scss/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
}

.container--content {
margin-top: 1.5rem;
}

.action-site-index .container--content {
margin-top: 2.5rem;
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/LessonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function actionIndex($path = ''): string
}

/**
* @phpstan-return array<int, array{"label": string, "url": string}>
* @phpstan-return array<int, array{"label": string, "url": string}|string>
*/
protected function getBreadcrumbs(Lesson $model): array
{
Expand All @@ -72,6 +72,7 @@ protected function getBreadcrumbs(Lesson $model): array
'url' => $parent->url
];
}
$breadcrumbs[] = $model->menuTitle;
return $breadcrumbs;
}
}
3 changes: 3 additions & 0 deletions views/_partials/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<?php
$delim = '';
foreach ($categories as $category) {
if (is_string($category)) {
continue;
}
echo $delim;
echo app\helpers\Html::a($category['label'], $category['url'], ['class' => 'meta__link']);
$delim = ' &gt; ';
Expand Down
2 changes: 1 addition & 1 deletion views/blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use app\widgets\LinkPager;

$this->title = 'Blog';
$this->params['breadcrumbs'][] = 'Blog';
$this->params['breadcrumbs'][] = 'Bass Blog';
$this->params['pageTitle'] = sprintf('Blog für Bassist*innen zum Thema E-Bass und Musik (%d/%d)', $pagination->page + 1, $pagination->pageCount);
$this->params['metaDescription'] = sprintf('Blog zum Thema E-Bass und Musik, mit inspirierenden und lesenswerten Artikeln aus der Welt der tiefen Töne (Seite %d von %d)', $pagination->page + 1, $pagination->pageCount);

Expand Down
5 changes: 1 addition & 4 deletions views/blog/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
$this->title = $blog->title . ' | Blog';
$this->params['pageTitle'] = $blog->pageTitle;
$this->params['metaDescription'] = $blog->metaDescription;
$this->params['breadcrumbs'][] = [
'label' => 'Blog',
'url' => Url::previous('blog')
];
$this->params['breadcrumbs'][] = ['label' => 'Bass Blog', 'url' => Url::previous('blog')];
$this->params['breadcrumbs'][] = $blog->title;
?>

Expand Down
54 changes: 54 additions & 0 deletions views/layouts/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,60 @@ function gtag(){dataLayer.push(arguments);}

<div class="container navbar-border-bottom"><div class="border"></div></div>

<?php if (!empty($this->params['breadcrumbs'])): ?>
<div class="container container--breadcumbList">
<ol vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="<?= Url::home() ?>">
<span property="name">Startseite</span></a>
<meta property="position" content="1">
</li>
<?php foreach ($this->params['breadcrumbs'] as $itemCount => $item): ?>
<?php if (is_array($item)): ?>
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="<?= Url::to($item['url']) ?>">
<span property="name"><?= $item['label'] ?></span></a>
<meta property="position" content="<?= $itemCount + 2 ?>">
</li>
<?php endif; ?>
<?php if (is_string($item)): ?>
<li property="itemListElement" typeof="ListItem">
<span property="name"><?= $item ?></span>
<meta property="position" content="<?= $itemCount + 2 ?>">
</li>
<?php endif; ?>
<?php endforeach; ?>
</ol>
<style>
up-modal .container--breadcumbList {
display: none;
}
ol[typeof=BreadcrumbList] {
list-style-type: none;
margin:1rem 0 0 0;
padding:0;
font-size: 0.9rem;
color: #c2c2c2;
}
li[typeof=ListItem] {
display: inline;
}
li[typeof=ListItem]::after {
content: " › ";
}
li:last-child[typeof=ListItem]::after {
content: "";
}
li[typeof=ListItem] a {
color: #c2c2c2;
}
li[typeof=ListItem] a:hover {
color: #7f7f7f;
}
</style>
</div>
<?php endif; ?>

<?php if (isset($this->blocks['jumbotron'])): ?>
<?= $this->blocks['jumbotron'] ?>
<?php endif; ?>
Expand Down
2 changes: 2 additions & 0 deletions views/sitemap/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use app\helpers\Html;

$this->title = 'Sitemap';
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="sitemap">
Expand All @@ -27,6 +28,7 @@
<h2 class="sitemap__section"><?= Html::a('Tools', ['/tools'], ['class' => 'sitemap__link']) ?></h2>
<ul class="sitemap__links">
<li><?= Html::a('Fingersätze für Tonleitern, Intervalle und Akkorde', ['/fingering/index'], ['class' => 'sitemap__link']) ?></li>
<li><?= Html::a('Online Metronom zum Üben', ['/tools/metronom'], ['class' => 'sitemap__link']) ?></li>
<li><?= Html::a('Notenpapier zum Herunterladen und Ausdrucken', ['/tool/musicpaper'], ['class' => 'sitemap__link']) ?></li>
</ul>
<h2 class="sitemap__section"><?= Html::a('Katalog', ['/catalog/overview'], ['class' => 'sitemap__link']) ?></h2>
Expand Down
9 changes: 9 additions & 0 deletions views/tool/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-12">
<h3 class="title"><?= Html::a('Online Metronom', ['/tools/metronom']) ?></h3>
<p>
Einfach bedienbares Online Metronom, das beim Üben eine Hilfe sein kann, um dein Timing, deine Rhythmik und deine musikalische Genauigkeit zu verbessern.
</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-12">
<h3 class="title"><?= Html::a('Blanko Notenpapier zum Herunterladen und Ausdrucken', ['/tool/musicpaper']) ?></h3>
Expand Down
7 changes: 7 additions & 0 deletions views/youtube-playlist/index.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?php

/**
* @var yii\web\View $this
* @var array $playlist
* @var array $playlistItems
*/

use yii\helpers\Url;

?>

<?php $this->title = $playlist['title'] . ' | Videos'; ?>
<?php $this->params['metaDescription'] = $playlist['description']; ?>
<?php $this->params['breadcrumbs'][] = ['label' => 'Videos', 'url' => Url::previous('video')]; ?>
<?php $this->params['breadcrumbs'][] = $playlist['title']; ?>

<h1><?= $playlist['title'] ?></h1>

<div class="widgetListSummary">
Expand Down
6 changes: 5 additions & 1 deletion views/youtube-playlist/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
* @var ?string $nextId
*/
?>

<?php $this->title = $playlistItem['title'] . ' | ' . $playlist['title'] . ' | Videos' ?>
<?php $this->params['breadcrumbs'][] = ['label' => 'Videos', 'url' => '/videos/']; ?>
<?php $this->params['breadcrumbs'][] = ['label' => $playlist['title'], 'url' => '/videos/' . $playlist['segment']]; ?>
<?php $this->params['breadcrumbs'][] = $playlistItem['title']; ?>

<h1><?= $playlistItem['title'] ?></h1>

<div class="ratio ratio--16x9">
Expand Down

0 comments on commit aba4473

Please sign in to comment.