$manager->assetUrl($args[0] ?? '', $args[1] ?? null), '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); } } if (! function_exists('go_url')) { /** * 外链中转:站外链接改写为 /go/{hash}(点击统计/拦截),站内链接原样返回。 */ function go_url(string $url): string { return app(\App\Blog\Services\UrlRedirector::class)->goUrl($url); } } if (! function_exists('comment_body')) { /** * 评论正文:转义 + 自动链接 URL(走 /go 中转,nofollow)。 */ function comment_body(string $text): string { $text = e($text); $text = preg_replace_callback( '#(https?://[^\s<>"\'()]+)#i', fn (array $m) => ''.$m[1].'', $text ); return nl2br($text); } }