Skip to main content

addCommand(page)

Add a page to CommandBar and returns a promise. This is especially useful for ingesting a sitemap and creating pages for each valid URL in a site.

Example

// Adds a Page
window.CommandBar.addCommand({
text: "Go to Home",
name: "go_to_page_home",
template: {
type: "link",
value: "/home",
operation: "self", // how should the page open
},
category: "Navigation",
});

Advanced - Adds a general 'Go to page' Action and provides each page as an argument

window.CommandBar.addCommand({
text: "Go to page",
name: "go_to_any_page",
template: {
type: "link",
value: "/{{pageName}}",
operation: "self",
},
arguments: {
pageName: {
type: "set",
value: ["home", "about", "contact"],
order_key: 1,
},
},
category: "Navigation",
});

// Wait for addCommand to complete
await window.CommandBar.addCommand({...});

Method parameters

page Required

object

The page schema.

PropertyTypeDescription
nameRequired
stringA unique identifier for the page
textRequired
stringThe label shown to the user in Spotlight
templateRequired
objectThe schema defining the page

template

object

PropertyTypeDescription
valueRequired
stringThe URL to open.