namespace App\Jobs;
use App\Models\Asset;
-use App\Models\Resource;
-use App\Models\Tour;
-use Cubist\Backpack\Magic\PageData;
use Cubist\Minisearch\Document;
use Cubist\Minisearch\Document\PDF;
use Cubist\Minisearch\Index;
public function __construct()
{
- $this->output = public_path('js/search.index.js');
+ $this->output = public_path('js/search.index.json');
}
public function handle()
{
- "name": "www",
+ "name": "ODL",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
+ "dependencies": {
+ "fs": "^0.0.1-security"
+ },
"devDependencies": {
"@alpinejs/intersect": "^3.4.2",
"@tailwindcss/line-clamp": "^0.2.2",
"node": ">= 0.6"
}
},
+ "node_modules/fs": {
+ "version": "0.0.1-security",
+ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+ "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
+ },
"node_modules/fs-extra": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
"dev": true
},
+ "fs": {
+ "version": "0.0.1-security",
+ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+ "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
+ },
"fs-extra": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
"postcss-import": "^14.0.2",
"smooth-scroll": "^16.1.3",
"tailwindcss": "^3.0.15"
+ },
+ "dependencies": {
+ "fs": "^0.0.1-security"
}
}
//=====================//
import MiniSearch from 'minisearch';
+import {readFile} from 'fs'
export default () => ({
async init() {
// We need the URL from the HTML because it gets properly updated when exporting the final version
- await loadScript(this.$el.dataset.searchindex);
-
- // Delay miniSearch initialisation so there's less chance of animations stuttering during page loads
- setTimeout(() => {
- window.minisearch = this.miniSearch = new MiniSearch(this.setup);
- this.miniSearch.addAllAsync(minisearchodl);
- }, 4000);
+ readFile(this.$el.dataset.searchindex, function (err, data) {
+ // Delay miniSearch initialisation so there's less chance of animations stuttering during page loads
+ setTimeout(() => {
+ window.minisearch = this.miniSearch = new MiniSearch();
+ this.miniSearch.loadJSON(data, this.setup)
+ }, 4000);
+ });
this.medialibrary = this.$el.dataset.medialibrary;
},
bg-white text-black
z-20"
{{-- Pass URLs in from HTML so JS will always have the correct version regardless of environment --}}
- data-searchindex="{{ asset('js/search.index.js') }}"
+ data-searchindex="{{ asset('js/search.index.json') }}"
data-medialibrary="{{ \App\Http\Controllers\FrontController::getLinkData('medialibrary')['url'] }}"
{{-- See js/search.js --}}
x-data="search()"