From dfbc9f9961b45d8ff58aac7106a709d423d00cdc Mon Sep 17 00:00:00 2001 From: Mike McNeil Date: Tue, 27 Apr 2021 13:08:33 -0500 Subject: [PATCH] Fixes issue #0 (#688) * option 1 (this is the quickest fix) * option 2: This shows how to handle it inline * whoops, fix prev commit (I forgot to pull out of the "if") * closes https://github.com/fleetdm/fleet/issues/0 -- this remove headerClass altogether in favor of using existing "page" local, eliminating the need for a headerClass view local -- see https://github.com/fleetdm/fleet/issues/0#issuecomment-827752563 for explanation * one further simplification that avoids `page` getting unintentionally used elsewhere in other .ejs files (also isHomepage is easier to cmd+f and find in code) --- website/config/routes.js | 8 ++++---- website/views/layouts/layout.ejs | 16 +++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/website/config/routes.js b/website/config/routes.js index b2200a8ba0..be89883e3d 100644 --- a/website/config/routes.js +++ b/website/config/routes.js @@ -13,7 +13,7 @@ module.exports.routes = { // ╦ ╦╔═╗╔╗ ╔═╗╔═╗╔═╗╔═╗╔═╗ // ║║║║╣ ╠╩╗╠═╝╠═╣║ ╦║╣ ╚═╗ // ╚╩╝╚═╝╚═╝╩ ╩ ╩╚═╝╚═╝╚═╝ - 'GET /': { action: 'view-homepage-or-redirect', locals: { page: 'homepage', headerClass: 'homepage-header' } }, + 'GET /': { action: 'view-homepage-or-redirect', locals: { isHomepage: true } }, '/blog': 'https://medium.com/fleetdm', @@ -31,9 +31,9 @@ module.exports.routes = { '/company/about': '/blog', // FUTURE: brief "about" page explaining the origins of the company '/company/stewardship': 'https://github.com/fleetdm/fleet', // FUTURE: page about how we approach open source and our commitments to the community - 'GET /company/contact': { action: 'view-contact', locals: { page: 'contact', headerClass: 'header' } }, - 'GET /get-started': { action: 'view-get-started', locals: { page: 'get-started', headerClass: 'header' } }, - 'GET /pricing': { action: 'view-pricing', locals: { page: 'pricing', headerClass: 'header' } }, + 'GET /company/contact': { action: 'view-contact' }, + 'GET /get-started': { action: 'view-get-started' }, + 'GET /pricing': { action: 'view-pricing' }, '/try-fleet': '/get-started', '/documentation': 'https://github.com/fleetdm/fleet/tree/master/docs', '/contribute': 'https://github.com/fleetdm/fleet/tree/master/docs/3-Contribution', diff --git a/website/views/layouts/layout.ejs b/website/views/layouts/layout.ejs index 08a477b96b..99546097de 100644 --- a/website/views/layouts/layout.ejs +++ b/website/views/layouts/layout.ejs @@ -1,8 +1,10 @@ -<% if(typeof me === 'undefined') { +<% // In case we're displaying the 404 or 500 page and relevant code in the "custom" hook was not able to run, - // we make sure `me` exists. This ensures we don't have to do `typeof` checks below. - var me = undefined; -} %> + // we make sure certain view locals exist that are commonly used in this layout.ejs file. This ensures we + // don't have to do `typeof` checks below. + var me; + var isHomepage; +%> Fleet for osquery | Open source device management @@ -50,10 +52,10 @@
-