refactor(routes): canonical URLs now match sablog format exactly
- /show-{id}.shtml (comments page: /show-{id}-{page}.shtml)
- /category-{cid}.shtml / /category-{cid}-{page}.shtml
- /archives-{YYYYMM}.shtml / /archives-{YYYYMM}-{page}.shtml
- /tag/{name}, /tagslist.shtml, /index-{page}.shtml
- slug 时代的 /posts/{slug} 等旧格式全部 301 到 sablog 格式
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
<ul class="archive-list">
|
||||
@foreach($months as $month => $monthPosts)
|
||||
<li>
|
||||
<a href="{{ route('archives.month', [$year, $month]) }}">{{ (int) $month }} 月</a>
|
||||
<a href="{{ route('archives.month', $year.$month) }}">{{ (int) $month }} 月</a>
|
||||
<span class="count">({{ $monthPosts->count() }} 篇)</span>
|
||||
<ul class="archive-posts">
|
||||
@foreach($monthPosts as $post)
|
||||
<li><a href="{{ route('posts.show', $post->slug ?: $post->id) }}">{{ $post->title }}</a> <time>{{ $post->published_at->format(blog_setting('listtime', 'm-d')) }}</time></li>
|
||||
<li><a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a> <time>{{ $post->published_at->format(blog_setting('listtime', 'm-d')) }}</time></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="comment" id="comment-{{ $comment->id }}">
|
||||
<div class="comment-head">
|
||||
<strong>{{ $comment->author_name }}</strong>
|
||||
<span>· 评论于 <a href="{{ route('posts.show', $comment->post->slug ?: $comment->post->id) }}#comment-{{ $comment->id }}">{{ $comment->post->title }}</a></span>
|
||||
<span>· 评论于 <a href="{{ route('posts.show', $comment->post->id) }}#comment-{{ $comment->id }}">{{ $comment->post->title }}</a></span>
|
||||
<span class="comment-time">· {{ $comment->created_at->format(blog_setting('comment_timeformat', 'Y-m-d H:i')) }}</span>
|
||||
</div>
|
||||
<div class="comment-body">{!! nl2br(e($comment->content)) !!}</div>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
@foreach($posts as $post)
|
||||
<item>
|
||||
<title>{{ $post->title }}</title>
|
||||
<link>{{ route('posts.show', $post->slug ?: $post->id) }}</link>
|
||||
<guid isPermaLink="true">{{ route('posts.show', $post->slug ?: $post->id) }}</guid>
|
||||
<link>{{ route('posts.show', $post->id) }}</link>
|
||||
<guid isPermaLink="true">{{ route('posts.show', $post->id) }}</guid>
|
||||
<pubDate>{{ $post->published_at->toRssString() }}</pubDate>
|
||||
<description>{{ Str::limit(strip_tags($post->excerpt_or_fallback), 300) }}</description>
|
||||
@if($post->category)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</url>
|
||||
@foreach($posts as $post)
|
||||
<url>
|
||||
<loc>{{ route('posts.show', $post->slug ?: $post->id) }}</loc>
|
||||
<loc>{{ route('posts.show', $post->id) }}</loc>
|
||||
<lastmod>{{ $post->updated_at?->toAtomString() }}</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<article class="post-card {{ $post->is_sticky ? 'sticky' : '' }}">
|
||||
@if($cover = $post->getFirstMedia('cover'))
|
||||
<a href="{{ route('posts.show', $post->slug ?: $post->id) }}" class="post-cover">
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="post-cover">
|
||||
<img src="{{ $cover->getUrl('card') ?: $cover->getUrl() }}" alt="{{ $post->title }}" loading="lazy">
|
||||
</a>
|
||||
@endif
|
||||
<h2 class="post-title">
|
||||
@if($post->is_sticky)<span class="badge">置顶</span>@endif
|
||||
<a href="{{ route('posts.show', $post->slug ?: $post->id) }}">{{ $post->title }}</a>
|
||||
<a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a>
|
||||
</h2>
|
||||
<div class="post-meta">
|
||||
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
|
||||
@if($post->category)
|
||||
<span>·</span>
|
||||
<a href="{{ route('category.show', $post->category->slug ?: $post->category->id) }}">{{ $post->category->name }}</a>
|
||||
<a href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a>
|
||||
@endif
|
||||
<span>· 阅读 {{ $post->views }}</span>
|
||||
<span>· 评论 {{ $post->comment_count }}</span>
|
||||
@@ -21,9 +21,9 @@
|
||||
{{ Str::limit(strip_tags($post->excerpt_or_fallback), 200) }}
|
||||
</div>
|
||||
<div class="post-footer">
|
||||
<a href="{{ route('posts.show', $post->slug ?: $post->id) }}" class="read-more">阅读全文 »</a>
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="read-more">阅读全文 »</a>
|
||||
@foreach($post->tags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->slug ?: $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<ul class="widget-list">
|
||||
@forelse($categories as $category)
|
||||
<li>
|
||||
<a href="{{ route('category.show', $category->slug ?: $category->id) }}">{{ $category->name }}</a>
|
||||
<a href="{{ route('category.show', $category->id) }}">{{ $category->name }}</a>
|
||||
<span class="count">({{ $category->post_count }})</span>
|
||||
</li>
|
||||
@empty
|
||||
@@ -18,7 +18,7 @@
|
||||
<h3 class="widget-title">最新文章</h3>
|
||||
<ul class="widget-list">
|
||||
@forelse($recentPosts as $post)
|
||||
<li><a href="{{ route('posts.show', $post->slug ?: $post->id) }}">{{ $post->title }}</a></li>
|
||||
<li><a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a></li>
|
||||
@empty
|
||||
<li>暂无文章</li>
|
||||
@endforelse
|
||||
@@ -30,7 +30,7 @@
|
||||
<ul class="widget-list">
|
||||
@forelse($recentComments as $comment)
|
||||
<li>
|
||||
<a href="{{ route('posts.show', $comment->post->slug ?: $comment->post->id) }}#comment-{{ $comment->id }}">
|
||||
<a href="{{ route('posts.show', $comment->post->id) }}#comment-{{ $comment->id }}">
|
||||
{{ $comment->author_name }}:{{ Str::limit(strip_tags($comment->content), 30) }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -44,7 +44,7 @@
|
||||
<h3 class="widget-title">标签云</h3>
|
||||
<div class="tag-cloud">
|
||||
@forelse($hotTags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->slug ?: $tag->name) }}" class="tag-link">{{ $tag->name }}</a>
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link">{{ $tag->name }}</a>
|
||||
@empty
|
||||
<span>暂无标签</span>
|
||||
@endforelse
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
|
||||
@if($post->author)<span>· {{ $post->author->name }}</span>@endif
|
||||
@if($post->category)
|
||||
<span>· <a href="{{ route('category.show', $post->category->slug ?: $post->category->id) }}">{{ $post->category->name }}</a></span>
|
||||
<span>· <a href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a></span>
|
||||
@endif
|
||||
<span>· 阅读 {{ $post->views }}</span>
|
||||
</div>
|
||||
@@ -53,7 +53,7 @@
|
||||
@if($post->tags->isNotEmpty())
|
||||
<div class="post-tags">
|
||||
@foreach($post->tags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->slug ?: $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<h1 class="list-title">全部标签</h1>
|
||||
<div class="tag-cloud big">
|
||||
@forelse($tags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->slug ?: $tag->name) }}" class="tag-link" style="font-size: {{ max(0.9, min(1.8, 0.9 + $tag->posts_count * 0.1)) }}em">
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link" style="font-size: {{ max(0.9, min(1.8, 0.9 + $tag->posts_count * 0.1)) }}em">
|
||||
{{ $tag->name }} ({{ $tag->posts_count }})
|
||||
</a>
|
||||
@empty
|
||||
|
||||
Reference in New Issue
Block a user