mirror of
https://github.com/eosswedenorg/apt
synced 2026-06-17 04:40:03 +02:00
move source js files (that should be bundled) from _scripts/ to assets/js/
This commit is contained in:
parent
f097ea57d7
commit
76623dfd2e
4 changed files with 2 additions and 2 deletions
36
assets/js/modules/alpine_search.js
Normal file
36
assets/js/modules/alpine_search.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
import pkg_idx from './pkg_idx'
|
||||
|
||||
// Alpine search component
|
||||
export default () => ({
|
||||
show: false,
|
||||
query: "",
|
||||
getResults() {
|
||||
if (this.query.length < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var results = pkg_idx.search(this.query).slice(0, 10);
|
||||
|
||||
var list = results.map(function (item) {
|
||||
return package_data.filter(function (v, i, arr) {
|
||||
return v.id == item.ref;
|
||||
})[0];
|
||||
});
|
||||
|
||||
this.open();
|
||||
return list;
|
||||
},
|
||||
toggle() {
|
||||
this.show = ! this.show;
|
||||
},
|
||||
open() {
|
||||
this.show = true;
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
},
|
||||
isOpen() {
|
||||
return this.show;
|
||||
}
|
||||
})
|
||||
14
assets/js/modules/pkg_idx.js
Normal file
14
assets/js/modules/pkg_idx.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
import lunr from 'lunr'
|
||||
|
||||
// Package Search using Lunr
|
||||
export default lunr(function () {
|
||||
this.field('name');
|
||||
this.field('version');
|
||||
this.field('repo');
|
||||
this.field('component');
|
||||
|
||||
package_data.forEach(function (pkg) {
|
||||
this.add(pkg);
|
||||
}, this);
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue