]> _ Git - odl.git/commitdiff
wip #4804
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Jan 2022 16:15:14 +0000 (17:15 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Jan 2022 16:15:14 +0000 (17:15 +0100)
resources/js/search.js
resources/views/components/search.blade.php

index fb6effdd4978a819c13f694027b5e2eb419ba651..b664da393a650e4e943627a4ba98af5fa6c71ed9 100644 (file)
@@ -4,11 +4,11 @@
 
 import MiniSearch from 'minisearch';
 
-export default (searchData = []) => ({
+export default () => ({
 
     miniSearch: {}, // Holds the MiniSearch instance
     setup: { // MiniSearch options: https://lucaong.github.io/minisearch/#search-options
-        fields: ['title', 'text','keywords'], // fields to index for full-text search
+        fields: ['title', 'text', 'keywords'], // fields to index for full-text search
         storeFields: ['id', 'title', 'text', 'type', 'url', 'thumb'], // fields to return with search results
         searchOptions: {
             prefix: true, // Allow partial matches
@@ -17,9 +17,8 @@ export default (searchData = []) => ({
     query: '', // The search query
 
     async init() {
-
         this.miniSearch = new MiniSearch(this.setup);
-        await loadScript('search.index.js');
+        await loadScript('../js/search.index.js');
         this.miniSearch.addAllAsync(minisearchodl);
     },
 
index c5bed4f57e467f9c1fef91fa72880e1e77e5302c..a7f670da5498b196e792f09d289374e400dcea49 100644 (file)
@@ -1,23 +1,10 @@
 {{-- SEARCH (full screen overlay) --}}
 
-@push('before_scripts')
-    <script>
-        @php
-            // TODO: Consider fetching this via JS only when search is used
-
-            // TODO: need to change Cubist/minisearch to output data differently but until then, can test it by copying the output manually into a .json file. Then use await / fetch to get data only when needed?
-            echo file_get_contents(storage_path('search.js'));
-            //echo 'var documents = [];';
-        @endphp
-    </script>
-@endpush
-
 <div class="overlay search-overlay
             bg-white text-black
             z-20"
-     {{-- Pass search index [documents] to component for setup --}}
      {{-- See js/search.js --}}
-     x-data="search(documents)"
+     x-data="search()"
      x-show="searchOpen"
      x-transition:enter.opacity.duration.500ms
      x-transition:leave.opacity.duration.200ms