optimizations
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
@php
|
||||
$gridVersion = request()->query('grid') === 'v2' ? 'v2' : 'v1';
|
||||
$deferToolbarSearch = request()->routeIs('index');
|
||||
$metaDescription = trim($__env->yieldContent('meta-description', $page_meta_description ?? ''));
|
||||
$metaKeywords = trim($__env->yieldContent('meta-keywords', $page_meta_keywords ?? ''));
|
||||
$novaViteEntries = [
|
||||
'resources/css/app.css',
|
||||
'resources/css/nova-grid.css',
|
||||
'resources/scss/nova.scss',
|
||||
'resources/js/nova.js',
|
||||
];
|
||||
|
||||
if (!$deferToolbarSearch) {
|
||||
$novaViteEntries[] = 'resources/js/entry-search.jsx';
|
||||
}
|
||||
@endphp
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}" data-grid-version="{{ $gridVersion }}">
|
||||
@@ -9,8 +22,8 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta name="description" content="{{ $page_meta_description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $page_meta_keywords ?? '' }}">
|
||||
<meta name="description" content="{{ $metaDescription }}">
|
||||
<meta name="keywords" content="{{ $metaKeywords }}">
|
||||
@isset($page_robots)
|
||||
<meta name="robots" content="{{ $page_robots }}" />
|
||||
@endisset
|
||||
@@ -35,9 +48,7 @@
|
||||
<link rel="shortcut icon" href="/favicon/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/favicon/site.webmanifest" />
|
||||
|
||||
|
||||
@vite(['resources/css/app.css','resources/css/nova-grid.css','resources/scss/nova.scss','resources/js/nova.js','resources/js/entry-search.jsx'])
|
||||
@vite($novaViteEntries)
|
||||
<style>
|
||||
/* Card enter animation */
|
||||
.nova-card-enter { opacity: 0; transform: translateY(10px) scale(0.995); }
|
||||
@@ -66,6 +77,61 @@
|
||||
[x-cloak] { display: none !important; }
|
||||
</style>
|
||||
@stack('head')
|
||||
|
||||
@if($deferToolbarSearch)
|
||||
<script type="module">
|
||||
(() => {
|
||||
const searchEntryUrl = @js(Vite::asset('resources/js/entry-search.jsx'));
|
||||
const triggerEvents = ['pointerdown', 'touchstart', 'focusin'];
|
||||
let searchLoaded = false;
|
||||
|
||||
const loadSearch = () => {
|
||||
if (searchLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchLoaded = true;
|
||||
cleanup();
|
||||
import(searchEntryUrl);
|
||||
};
|
||||
|
||||
const onReady = () => {
|
||||
const searchRoot = document.getElementById('topbar-search-root');
|
||||
if (!searchRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
triggerEvents.forEach((eventName) => {
|
||||
searchRoot.addEventListener(eventName, loadSearch, { once: true, passive: true });
|
||||
});
|
||||
|
||||
if ('requestIdleCallback' in window) {
|
||||
window.requestIdleCallback(loadSearch, { timeout: 2000 });
|
||||
} else {
|
||||
window.setTimeout(loadSearch, 1500);
|
||||
}
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
const searchRoot = document.getElementById('topbar-search-root');
|
||||
if (!searchRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
triggerEvents.forEach((eventName) => {
|
||||
searchRoot.removeEventListener(eventName, loadSearch);
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', onReady, { once: true });
|
||||
} else {
|
||||
onReady();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@if(isset($page) && is_array($page))
|
||||
@inertiaHead
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user