refactor(routes): canonical URLs now match sablog format exactly
Build and Deploy / verify (push) Successful in 1m6s
Build and Deploy / deploy (push) Successful in 41s

- /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:
2026-09-09 21:21:07 +00:00
parent f6a9a8ea50
commit f5987e7cc2
22 changed files with 113 additions and 70 deletions
+7 -7
View File
@@ -78,7 +78,7 @@ class LegacyController extends Controller
$tag = Tag::findFromString($name, 'post');
return $tag
? redirect()->route('tags.show', $tag->slug ?: $tag->name, 301)
? redirect()->route('tags.show', $tag->name, 301)
: abort(404);
}
@@ -152,7 +152,7 @@ class LegacyController extends Controller
app(\App\Blog\Support\PluginManager::class)->doAction('comment.created', $comment);
return redirect()->route('posts.show', $post->slug ?: $post->id)
return redirect()->route('posts.show', $post->id)
->with($status === 'published' ? 'success' : 'error', $status === 'published' ? '评论已发布' : '评论已提交,等待审核')
->withFragment('comments');
}
@@ -162,7 +162,7 @@ class LegacyController extends Controller
$post = Post::find($id);
return $post
? redirect()->route('posts.show', $post->slug ?: $post->id, 301)
? redirect()->route('posts.show', $post->id, 301)
: abort(404);
}
@@ -171,7 +171,7 @@ class LegacyController extends Controller
$category = Category::find($cid);
return $category
? redirect()->route('category.show', $category->slug ?: $category->id, 301)
? redirect()->route('category.show', $category->id, 301)
: abort(404);
}
@@ -185,8 +185,8 @@ class LegacyController extends Controller
$month = $m[2] ?? null;
return $month
? redirect()->route('archives.month', [$year, $month], 301)
: redirect()->route('archives.month', [$year, '01'], 301);
? redirect()->route('archives.month', $year.$month, 301)
: redirect()->route('archives.month', $year.'01', 301);
}
private function tagList(Request $request)
@@ -198,7 +198,7 @@ class LegacyController extends Controller
$tag = $tagId ? Tag::find((int) $tagId) : Tag::find((int) $request->query('id'));
return $tag
? redirect()->route('tags.show', $tag->slug ?: $tag->name, 301)
? redirect()->route('tags.show', $tag->name, 301)
: abort(404);
}