From 726889bed1e9271ce640cb00a9c4952aa44fc7f5 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 18 Oct 2024 00:54:30 -0500 Subject: [PATCH] Website: Add search to article category page. (#22997) Closes: #22952 Changes: - Removed the categories from the article landing page. - Updated the announcements article category page and article landing page to have a search bar --- .../assets/js/pages/articles/articles.page.js | 95 ++++++++----------- website/views/layouts/layout.ejs | 2 + website/views/pages/articles/articles.ejs | 90 +++++++----------- 3 files changed, 76 insertions(+), 111 deletions(-) diff --git a/website/assets/js/pages/articles/articles.page.js b/website/assets/js/pages/articles/articles.page.js index 8aa5dc2600..cf15625714 100644 --- a/website/assets/js/pages/articles/articles.page.js +++ b/website/assets/js/pages/articles/articles.page.js @@ -16,53 +16,51 @@ parasails.registerPage('articles', { beforeMount: function() { // Using the category to articles, - - if (this.category === 'all') { - // if the category is set to 'all', we'll show the articles landing page and set `isArticlesLandingPage` to true - this.isArticlesLandingPage = true; - } else { - switch(this.category) { - // If a specific category was provided, we'll set the articleCategory and categoryDescription. - case 'success-stories': - this.articleCategory = 'Success stories'; - this.categoryDescription = 'Read about how others are using Fleet and osquery.'; - break; - case 'securing': - this.articleCategory = 'Security'; - this.categoryDescription = 'Learn more about how we secure Fleet.'; - break; - case 'releases': - this.articleCategory = 'Releases'; - this.categoryDescription = 'Read about the latest release of Fleet.'; - break; - case 'engineering': - this.articleCategory = 'Engineering'; - this.categoryDescription = 'Read about engineering at Fleet and beyond.'; - break; - case 'guides': - this.articleCategory = 'Guides'; - this.categoryDescription = 'Learn more about how to use Fleet to accomplish your goals.'; - break; - case 'announcements': - this.articleCategory = 'Announcements'; - this.categoryDescription = 'The latest news from Fleet.'; - break; - case 'podcasts': - this.articleCategory = 'Podcasts'; - this.categoryDescription = 'Listen to the Future of Device Management podcast'; - break; - case 'report': - this.articleCategory = 'Reports'; - this.categoryDescription = ''; - break; - } + switch(this.category) { + // If a specific category was provided, we'll set the articleCategory and categoryDescription. + case 'success-stories': + this.articleCategory = 'Success stories'; + this.categoryDescription = 'Read about how others are using Fleet and osquery.'; + break; + case 'securing': + this.articleCategory = 'Security'; + this.categoryDescription = 'Learn more about how we secure Fleet.'; + break; + case 'releases': + this.articleCategory = 'Releases'; + this.categoryDescription = 'Read about the latest release of Fleet.'; + break; + case 'engineering': + this.articleCategory = 'Engineering'; + this.categoryDescription = 'Read about engineering at Fleet and beyond.'; + break; + case 'guides': + this.articleCategory = 'Guides'; + this.categoryDescription = 'Learn more about how to use Fleet to accomplish your goals.'; + break; + case 'announcements': + this.articleCategory = 'Announcements'; + this.categoryDescription = 'The latest news from Fleet.'; + break; + case 'podcasts': + this.articleCategory = 'Podcasts'; + this.categoryDescription = 'Listen to the Future of Device Management podcast'; + break; + case 'report': + this.articleCategory = 'Reports'; + this.categoryDescription = ''; + break; + case 'all': + this.articleCategory = 'Articles'; + this.categoryDescription = 'Read the latest articles from the Fleet team and community.'; + break; } // Sorting articles on the page based on their 'publishedOn' date. this.sortArticlesByDate(); }, mounted: async function() { - if(this.category === 'guides') { + if(['Articles', 'Announcements', 'Guides'].includes(this.articleCategory)) { if(this.algoliaPublicKey) {// Note: Docsearch will only be enabled if sails.config.custom.algoliaPublicKey is set. If the value is undefined, the handbook search will be disabled. docsearch({ appId: 'NZXAYZXDGH', @@ -73,7 +71,7 @@ parasails.registerPage('articles', { debug: false, clickAnalytics: true, searchParameters: { - facetFilters: ['section:guides'] + facetFilters: ['section:articles'] }, }); } @@ -97,19 +95,6 @@ parasails.registerPage('articles', { } }); }, - - filterBy: function(filter) { - if(filter !== 'all') { - this.selectedArticles = this.articles.filter((article)=>{ - if(article.meta['category'] === filter) { - return article; - } - }); - } else { - this.sortArticlesByDate(); - } - this.filter = filter; - }, clickCopyRssLink: function(articleCategory) { let rssButton = $('a[purpose="rss-button"]'); if(typeof navigator.clipboard !== 'undefined' && rssButton) { diff --git a/website/views/layouts/layout.ejs b/website/views/layouts/layout.ejs index c8a438213f..986408f456 100644 --- a/website/views/layouts/layout.ejs +++ b/website/views/layouts/layout.ejs @@ -187,6 +187,7 @@ News Podcasts Articles + Success stories COMPANY
Handbook @@ -247,6 +248,7 @@ News Podcasts Articles + Success stories COMPANY Handbook Logos/artwork diff --git a/website/views/pages/articles/articles.ejs b/website/views/pages/articles/articles.ejs index 4b21814af3..f3cf3e2677 100644 --- a/website/views/pages/articles/articles.ejs +++ b/website/views/pages/articles/articles.ejs @@ -1,27 +1,30 @@