This commit is contained in:
Alisa
2026-06-07 21:14:30 +03:00
parent 76bf5d8191
commit 66e931e0d6
14 changed files with 1079 additions and 12 deletions
+14
View File
@@ -22,6 +22,20 @@ function base_path(string $path = ''): string
return $path === '' ? $base : $base . '/' . ltrim($path, '/');
}
function versioned_asset(string $path): string
{
$assetPath = '/' . ltrim($path, '/');
$pathWithoutQuery = strtok($assetPath, '?') ?: $assetPath;
$querySeparator = str_contains($assetPath, '?') ? '&' : '?';
$publicPath = base_path('public' . $pathWithoutQuery);
if (!is_file($publicPath)) {
return $assetPath;
}
return $assetPath . $querySeparator . filemtime($publicPath);
}
function view(string $template, array $data = []): void
{
View::render($template, $data);