feat: sync latest GPT SEO routing and docs
This commit is contained in:
@@ -22,37 +22,57 @@ $strTmpCode = $siteContext->getTemplate();
|
||||
if ($strTmpCode == 'videoGpt1') {
|
||||
// if (env('IS_GPT_TMP', false)) {
|
||||
|
||||
$routeGetHead = static function (string $route, $handler) {
|
||||
return Route::rule($route, $handler, 'GET|HEAD');
|
||||
};
|
||||
|
||||
// ---------- Common public routes (keep compatible) ----------
|
||||
Route::get('/robots', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
$routeGetHead('/robots', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return view('sitemap/robots.txt');
|
||||
})->ext('txt');
|
||||
|
||||
Route::get('/sitemap', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
$routeGetHead('/sitemap', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return view('video/getMap.html');
|
||||
})->ext('html');
|
||||
|
||||
Route::get('rss/baidu', function () {
|
||||
$routeGetHead('/sitemap.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('INDEX');
|
||||
});
|
||||
|
||||
$routeGetHead('rss/baidu', function () {
|
||||
return view('rss/baidu.xml')->contentType('text/xml');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('rss/so', function () {
|
||||
$routeGetHead('rss/so', function () {
|
||||
return view('rss/so.xml')->contentType('text/xml');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap_index', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
$routeGetHead('/sitemap_index', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('INDEX');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap-main', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
$routeGetHead('/sitemap_index.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('INDEX');
|
||||
});
|
||||
|
||||
$routeGetHead('/sitemap-main', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('MAIN');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap-videos-:page', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
$routeGetHead('/sitemap-main.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('MAIN');
|
||||
});
|
||||
|
||||
$routeGetHead('/sitemap-videos-:page', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('VIDEO');
|
||||
})->ext('xml');
|
||||
|
||||
$routeGetHead('/sitemap-videos-:page.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('VIDEO');
|
||||
});
|
||||
|
||||
// 榜单首页历史深链优先硬绑定,避免被通用 rank_list 模式误吞到列表页模板。
|
||||
Route::get('/phb-index', function () {
|
||||
$routeGetHead('/phb-index', function () {
|
||||
return view('video/getRankIndex.html');
|
||||
});
|
||||
|
||||
@@ -67,13 +87,13 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
string $route,
|
||||
string $view,
|
||||
array $pattern = []
|
||||
) use (&$registered) {
|
||||
) use (&$registered, $routeGetHead) {
|
||||
|
||||
if (isset($registered[$route])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = Route::get($route, fn() => view($view));
|
||||
$r = $routeGetHead($route, fn() => view($view));
|
||||
|
||||
if ($pattern) {
|
||||
$r->pattern($pattern);
|
||||
@@ -88,7 +108,7 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
if (str_ends_with($route, '.html')) {
|
||||
$routeWithoutExt = substr($route, 0, -5);
|
||||
if ($routeWithoutExt !== '' && !isset($registered[$routeWithoutExt])) {
|
||||
$alias = Route::get($routeWithoutExt, fn() => view($view))->ext('html');
|
||||
$alias = $routeGetHead($routeWithoutExt, fn() => view($view))->ext('html');
|
||||
if ($pattern) {
|
||||
$alias->pattern($pattern);
|
||||
}
|
||||
@@ -163,7 +183,7 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
|
||||
case 'detail':
|
||||
$register($route, 'video/getVideoInfo.html', [
|
||||
'intVId' => '\d+',
|
||||
'intVId' => '\d*',
|
||||
'strPinyin' => '[\w-]+'
|
||||
]);
|
||||
break;
|
||||
@@ -255,6 +275,9 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
'/shipin-neiron/:intVId-:intVForgeId',
|
||||
],
|
||||
'detail' => [
|
||||
'/detail/:strPinyin',
|
||||
'/detail/pinyin-:strPinyin',
|
||||
'/detail/:strPinyin/:intVForgeId',
|
||||
'/voddetail/:strPinyin-:intVId',
|
||||
'/vodinfo/:strPinyin-:intVId',
|
||||
'/vod/:strPinyin-:intVId',
|
||||
@@ -327,8 +350,9 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
|
||||
case 'detail':
|
||||
$register($route, 'video/getVideoInfo.html', [
|
||||
'intVId' => '\d+',
|
||||
'intVId' => '\d*',
|
||||
'strPinyin' => '[\w-]+',
|
||||
'intVForgeId' => '\d*',
|
||||
]);
|
||||
break;
|
||||
|
||||
@@ -374,6 +398,10 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
return view('video/getMap.html');
|
||||
})->ext('html');
|
||||
|
||||
Route::get('/sitemap.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('INDEX');
|
||||
});
|
||||
|
||||
/**
|
||||
* /rss/baidu
|
||||
*/
|
||||
@@ -398,6 +426,10 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
// return view('sitemap/sitemap_index.xml');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap_index.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('INDEX');
|
||||
});
|
||||
|
||||
/**
|
||||
* 首页、分类列表、排行榜、男生/女生频道。
|
||||
*/
|
||||
@@ -406,6 +438,10 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
// return view('sitemap/sitemap-main.xml');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap-main.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('MAIN');
|
||||
});
|
||||
|
||||
/**
|
||||
* 小说目录页面。
|
||||
*/
|
||||
@@ -445,6 +481,10 @@ if ($strTmpCode == 'videoGpt1') {
|
||||
// return view('sitemap/sitemap-books.xml');
|
||||
})->ext('xml');
|
||||
|
||||
Route::get('/sitemap-videos-:page.xml', function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return $SiteContext->getSiteMapByCode('VIDEO');
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 搜索首页
|
||||
|
||||
Reference in New Issue
Block a user