/** * * ----------------------------------------------------------------------------- * A navigation bar with a search box. * * @type {Component} * * ----------------------------------------------------------------------------- */ parasails.registerComponent('docsNavAndSearch', { // ╔═╗╦═╗╔═╗╔═╗╔═╗ // ╠═╝╠╦╝║ ║╠═╝╚═╗ // ╩ ╩╚═╚═╝╩ ╚═╝ props: [ 'searchFilter', 'algoliaPublicKey', 'currentSection', ], // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗ // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣ // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝ data: function (){ return { //… }; }, // ╦ ╦╔╦╗╔╦╗╦ // ╠═╣ ║ ║║║║ // ╩ ╩ ╩ ╩ ╩╩═╝ template: `
`, // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗ // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣ // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝ beforeMount: function() { //… }, mounted: async function() { let filterForSearch = {}; if(this.searchFilter){ let searchIndexesThatExist = ['docs', 'software', 'queries', 'vitals', 'policies', 'tables', 'handbook', 'software']; if(!searchIndexesThatExist.includes(this.searchFilter)){ throw new Error(`Invalid 'searchFilter' value provided to component. Please change the searchFilter value to one of: ${searchIndexesThatExist.join(', ')}`); } filterForSearch = { 'facetFilters': [`section:${this.searchFilter}`] }; } if(this.algoliaPublicKey) { docsearch({ appId: 'NZXAYZXDGH', apiKey: this.algoliaPublicKey, indexName: 'fleetdm', container: '#docsearch-query', placeholder: 'Search', debug: false, searchParameters: filterForSearch, }); } }, beforeDestroy: function() { //… }, // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗ // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ methods: { //… }, });