fleet/website/api/controllers/view-query-detail.js
Mike Thomas e80d1ac717
Website update page titles and descriptions (#15645)
Closes https://github.com/fleetdm/fleet/issues/15615

_I'm sorry, I should have split this into separate PRs. I was trying to
move fast, but I didn't consider how awkward to review this PR would
become._

- Updated page titles and descriptions for:
- Homepage (no change to description. Currently set to the default blurb
from "Why Fleet doc."
    - `/pricing`
    - `/integrations`
    - `/vulnerability-management`
    - `/endpoint-ops`
- `/device-management` (I'm not super happy with this one. I tried to
summarize everything, but I think it's too long. I probably need to
rewrite it in a fast follow PR)
- Renamed `/osquery-management` to `/endpoint-ops` and set up redirect
- Removed `/compliance` (Note: I did not remove the compliance feature
images as they are referenced in various /imagine land pages. I need to
confirm whether those imagine pages are used in active ads?)

---------

Co-authored-by: Eric <[email protected]>
2023-12-15 08:06:31 +09:00

51 lines
1.8 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View query detail',
description: 'Display "Query detail" page.',
inputs: {
slug: { type: 'string', required: true, description: 'A slug uniquely identifying this query in the library.', example: 'get-macos-disk-free-space-percentage' },
},
exits: {
success: { viewTemplatePath: 'pages/query-detail' },
notFound: { responseType: 'notFound' },
badConfig: { responseType: 'badConfig' },
},
fn: async function ({ slug }) {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.queries)) {
throw {badConfig: 'builtStaticContent.queries'};
} else if (!_.isString(sails.config.builtStaticContent.queryLibraryYmlRepoPath)) {
throw {badConfig: 'builtStaticContent.queryLibraryYmlRepoPath'};
}
// Serve appropriate content for query.
// > Inspired by https://github.com/sailshq/sailsjs.com/blob/b53c6e6a90c9afdf89e5cae00b9c9dd3f391b0e7/api/controllers/documentation/view-documentation.js
let query = _.find(sails.config.builtStaticContent.queries, { slug: slug });
if (!query) {
throw 'notFound';
}
// Setting the meta title and description of this page using the query object, and falling back to a generic title or description if query.name or query.description are missing.
let pageTitleForMeta = query.name ? query.name + ' | Query details' : 'Query details | Fleet';
let pageDescriptionForMeta = query.description ? query.description : 'View more information about a query in Fleet\'s standard query library';
// Respond with view.
return {
query,
queryLibraryYmlRepoPath: sails.config.builtStaticContent.queryLibraryYmlRepoPath,
pageTitleForMeta,
pageDescriptionForMeta,
};
}
};