M2: 主题系统(sablog经典+modern简约)+ 前台全部页面 + 老 URL 301 兼容 + markdown 双份导入

This commit is contained in:
ak
2026-08-11 17:58:29 +08:00
parent f16bb75538
commit 6214976a88
66 changed files with 2763 additions and 10 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace App\Blog\Controllers;
use App\Models\Post;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
class FeedController extends Controller
{
public function rss()
{
$posts = Post::query()
->published()
->latest('published_at')
->limit((int) blog_setting('rss_num', config('blog.rss_num')))
->with('category', 'author', 'tags')
->get();
$content = view('feed.rss', [
'posts' => $posts,
'siteName' => blog_setting('site_name', config('blog.name')),
'siteDescription' => blog_setting('site_description', config('blog.description')),
'xmlDeclaration' => '<?xml version="1.0" encoding="UTF-8"?>',
])->render();
return response($content)->header('Content-Type', 'application/rss+xml; charset=utf-8');
}
public function sitemap()
{
$posts = Post::query()
->published()
->latest('published_at')
->get(['id', 'slug', 'updated_at']);
$content = view('feed.sitemap', [
'posts' => $posts,
'xmlDeclaration' => '<?xml version="1.0" encoding="UTF-8"?>',
])->render();
return response($content)->header('Content-Type', 'application/xml; charset=utf-8');
}
public function robots(): Response
{
$disallow = array_merge(config('robots.disallow'), (array) blog_setting('seo_robots_disallow', []));
$sitemap = config('robots.sitemap');
$lines = ['User-agent: *'];
foreach ($disallow as $path) {
$lines[] = "Disallow: {$path}";
}
$lines[] = "Sitemap: ".url($sitemap);
return response(implode("\n", $lines)."\n")->header('Content-Type', 'text/plain; charset=utf-8');
}
}