* chore: add husky pre-commit and pre-push hooks * feat: frontend audit — formulário de contato, a11y, SEO, performance e conteúdo * test: regenerate visual baselines from CI environment
42 lines
1.6 KiB
PHP
42 lines
1.6 KiB
PHP
@php
|
|
$manifestPath = public_path('build/fonts-manifest.json');
|
|
$hotManifestPath = public_path('hot') !== '' && is_file(public_path('build/fonts-manifest.dev.json'))
|
|
? public_path('build/fonts-manifest.dev.json')
|
|
: null;
|
|
|
|
$manifestFile = is_file($manifestPath) ? $manifestPath : $hotManifestPath;
|
|
$manifest = is_string($manifestFile) && is_file($manifestFile)
|
|
? \Illuminate\Support\Facades\Cache::remember(
|
|
'fonts-manifest:'.md5($manifestFile.':'.(string) filemtime($manifestFile)),
|
|
3600,
|
|
static fn () => json_decode((string) file_get_contents($manifestFile), true) ?: null,
|
|
)
|
|
: null;
|
|
|
|
$cssFile = is_array($manifest) ? ($manifest['style']['file'] ?? null) : null;
|
|
$preloads = is_array($manifest) ? ($manifest['preloads'] ?? []) : [];
|
|
$familyStyles = is_array($manifest) ? ($manifest['style']['familyStyles'] ?? []) : [];
|
|
$variables = is_array($manifest) ? ($manifest['style']['variables'] ?? []) : [];
|
|
@endphp
|
|
|
|
@if (is_array($manifest))
|
|
@foreach ($preloads as $preload)
|
|
<link
|
|
rel="preload"
|
|
as="{{ $preload['as'] ?? 'font' }}"
|
|
href="{{ asset('build/'.$preload['file']) }}"
|
|
type="{{ $preload['type'] ?? 'font/woff2' }}"
|
|
crossorigin="{{ $preload['crossorigin'] ?? 'anonymous' }}"
|
|
>
|
|
@endforeach
|
|
|
|
@if (filled($cssFile))
|
|
<link rel="stylesheet" href="{{ asset('build/'.$cssFile) }}">
|
|
@elseif ($familyStyles !== [])
|
|
<style>
|
|
{!! implode("\n", array_values($variables)) !!}
|
|
{!! implode("\n", array_values($familyStyles)) !!}
|
|
</style>
|
|
@endif
|
|
@endif
|