Skip to content

Commit

Permalink
Add twig support for robots.txt, humans.txt, and security.txt responses
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeTowers committed Aug 1, 2023
1 parent c59401d commit b339557
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b339557

Please sign in to comment.