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.
Property | Type | Description |
---|---|---|
nameRequired | string | A unique identifier for the page |
textRequired | string | The label shown to the user in Spotlight |
templateRequired | object | The schema defining the page |
template
object
Property | Type | Description |
---|---|---|
valueRequired | string | The URL to open. |