| name | Toggled CLI |
|---|---|
| description | Control Toggled with the command line. |
The Toggled CLI can be used to design and deploy sites and addons for Toggled.tech. This is intended for advanced developers.
Install it via NPM with:
npm i toggled-cliView the NPM package at https://www.npmjs.com/package/toggled-cli
Run:
toggled loginThe first step to designing anything with the Toggled CLI is creating a toggled.json file.
You can do this by running the following command in the terminal.
toggled init websiteThis will create a new toggled.json file with the type set to website.
You can refer the the rest of the documentation and tutorials for this.
Before you can deploy your site, make sure you fill out the name and author field in toggled.json.
{
"name": "{Site Name}",
"author": "{Your Name}"
}Next, reserve the name you want to use for your site. For example: toggled.tech/site/{Your Site Name}
toggled reserve {Your Site Name}Finally, deploy the site with the command below.
toggled deployFill out the template name:
{template name}The options are:
- page
- pages/docs
- pages/new
- pages/land
- pages/blank
The first step to designing anything with the Toggled CLI is creating a toggled.json file.
You can do this by running the following command in the terminal.
toggled init packageThis will create a new toggled.json file with the type set to package.
Design the custom elements in the file set as main in toggled.json.
export const BLOCKNAME = (e) => {
//e is the parent element of the block access dataset via e.dataset
const blockCode = `<p>Hello World</p>`;
return blockCode;
};You must return the block in an HTML format readable by the browser.
There are two ways to deploy your custom blocks. If you want full control over hosting then you can host it on your own servers statically. Then import it like this:
import { BLOCKNAME } from 'https://your-server.com/your-file.js'Your server must be https and configured for CORS. See https://toggled.tech/site/toggledtech-docs/Imports.
The other option it to deploy it directly from the CLI to our servers. This won't give you as much control but you will not have to worry about hosting.
Deploy it by running this command in terminal.
toggled packageThen import it like this:
import { BLOCKNAME } from 'PACKAGE_NAME'Your package name is specified as name in toggled.json. (Note even if the name has uppercases, the server will always make it lowercase)