From b3395579b23145a392ccb9a3f899cbab8a25df19 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Mon, 31 Jul 2023 18:18:44 -0600 Subject: [PATCH] Add twig support for robots.txt, humans.txt, and security.txt responses --- routes.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/routes.php b/routes.php index 4e69f34..83e6bed 100644 --- a/routes.php +++ b/routes.php @@ -4,7 +4,20 @@ Event::listen('system.beforeRoute', function () { $txtResponse = function ($key) { - $contents = Settings::get($key); + $cacheKey = 'winter.seo::txt_response.' . $key; + $contents = ''; + + if (Config::get('app.debug')) { + Cache::forget($cacheKey); + } + + $contents = Cache::rememberForever($cacheKey, function () use ($key) { + return Twig::parse(Settings::get($key), [ + 'app_url' => Config::get('app.url'), + 'app_name' => Config::get('app.name'), + 'app_debug' => Config::get('app.debug'), + ]); + }); if (empty($contents)) { return Response::make((new \Cms\Classes\Controller())->run('404'), 404);