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:
@@ -20,8 +20,17 @@ class ArchiveController extends Controller
|
||||
return theme_view('archives', compact('archives'));
|
||||
}
|
||||
|
||||
public function month(string $year, string $month)
|
||||
/**
|
||||
* sablog 格式:/archives-{YYYYMM}.shtml
|
||||
*/
|
||||
public function month(string $date)
|
||||
{
|
||||
if (! preg_match('/^(\d{4})(\d{2})$/', $date, $m)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
[$year, $month] = [$m[1], $m[2]];
|
||||
|
||||
$start = Carbon::create((int) $year, (int) $month, 1)->startOfMonth();
|
||||
$end = (clone $start)->endOfMonth();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user