-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag.blade.php
More file actions
78 lines (68 loc) · 2.58 KB
/
tag.blade.php
File metadata and controls
78 lines (68 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@php
$tag = urldecode(request_vars('t', false));
if ($tag) {
// Load tag archive
$pages = all_pages()->filter(function ($page) use ($tag) {
return in_array($tag, $page->tags ?: []);
})->sortByDesc('published');
$pagination = paginate($pages);
// Canonical
$canonical = $pagination->current()->url(request_url());
if ($pagination->hasPrevious()) {
$prev = $pagination->getPrevious()->url(request_url());
}
if ($pagination->hasNext()) {
$next = $pagination->getNext()->url(request_url());
}
}
@endphp
@extends('base', [
'title' => (($tag) ? '#'.$tag.' | ' : '').'Tag Archive',
'canonical' => $canonical ?? null,
'prev' => $prev ?? null,
'next' => $next ?? null,
])
@section('content')
<div class="page-header">
<div class="container container-md">
<div class="row">
<div class="col-12 text-center">
<h1>{{ $tag ? '#'.$tag : 'Popular tags' }}</h1>
</div>
</div>
</div>
</div>
<div class="container container-md">
<div class="row">
<div class="col-12">
@if($tag)
@if($pages->count())
@foreach($pagination->items() as $page)
@include('article', ['preview' => true, 'article' => $page])
@endforeach
@include('pagination', ['pagination' => $pagination])
@else
<p class="text-center"><em>No posts tagged "{{ $tag }}" found.</em></p>
@endif
@else
@php
$tags = [];
foreach (all_pages() as $page) {
$tags = array_merge($tags, $page->tags ?: []);
}
$popular = array_count_values($tags);
arsort($popular);
$top = array_slice($popular, 0, 30, true);
@endphp
<section class="content">
@foreach($top as $tag => $count)
<a class="tag" href="{{ app_url(ltrim(config('content.tag-route').urlencode($tag), '/')) }}">
{{ $tag }}
</a>
@endforeach
</section>
@endif
</div>
</div>
</div>
@endsection