The Toggled CLI
The Toggled CLI can be used to design and deploy sites and addons for Toggled.tech. This is intended for advanced developers.
Getting Started
Install it via NPM with:
npm i toggled-cli
View the NPM package at https://www.npmjs.com/package/toggled-cli
Logging In
Run:
toggled login
Developing Sites
toggled.json
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 website
This will create a new toggled.json file with the type set to website.
Designing and Developing
You can refer the the rest of the documentation and tutorials for this.
Deploying
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 deploy
Fill out the template name:
{template name}
The options are:
- page
- pages/docs
- pages/new
- pages/land
- pages/blank
Developing Packages
toggled.json
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 package
This will create a new toggled.json file with the type set to package.
Package Code
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.
Deployment
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 package
Then 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)