M2: 主题系统(sablog经典+modern简约)+ 前台全部页面 + 老 URL 301 兼容 + markdown 双份导入
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use App\Blog\Support\ThemeManager;
|
||||
|
||||
if (! function_exists('theme_view')) {
|
||||
/**
|
||||
* 渲染主题视图:激活主题目录已前置到全局视图路径,主题缺失时自动回退默认视图。
|
||||
*/
|
||||
function theme_view(string $view, array $data = []): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view($view, $data);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('theme')) {
|
||||
/**
|
||||
* 主题辅助函数:theme() / theme('asset', 'style.css') / theme('var', 'key', default)
|
||||
*/
|
||||
function theme(?string $method = null, ...$args): mixed
|
||||
{
|
||||
$manager = app(ThemeManager::class);
|
||||
|
||||
return match ($method) {
|
||||
'asset' => $manager->assetUrl($args[0] ?? ''),
|
||||
'var' => $manager->variable($args[0] ?? '', $args[1] ?? null),
|
||||
'vars' => $manager->variables(),
|
||||
'name' => $manager->active(),
|
||||
default => $manager,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('blog_setting')) {
|
||||
/**
|
||||
* 读取博客设置(Setting 表,带缓存)。
|
||||
*/
|
||||
function blog_setting(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return \App\Models\Setting::get($key, $default);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user