1.0.19 • Published 3 years ago

spear-cli v1.0.19

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

spear-cli

npm version

This is SSG(Static Site Generator) for Spearly.

Usage

Install

  1. npm
npm install spear-cli -g
  1. yarn
yarn global add spear-cli

Create project

As first step, you need to create:

  1. spear create : This command start wizard creating project.
Namespace(port=undefined, action='create', projectName=undefined, src=undefined)
 ### Welcome to Spear CLI ###


? Name of your project (spear-cli) <Input your project name>
? Use Spearly CMS (Use arrow keys)
āÆ Yes      <- Choose 'yes' if you use the Spear content.
  No
? Enter your Spearly CMS API KEY  <Input your Spearly API KEY>



? Name of your project SampleProject
? Use Spearly CMS Yes
? Enter your Spearly CMS API KEY aaaaaa

  ## Your project was created šŸŽ‰

  To start using, run the following command:
      cd SampleProject
      yarn install

  To start local server, run
      yarn dev

  To build static sources, run
      yarn build

If you finish wizard, your preparation for using spear-cli.

Editing pages

You can edit pages to you prefer. spear-cli support some features:

  • Components
    • You can create parts of pages as components.
  • assets
    • Images / Scripsts / CSS...
  • Insert Spearly content list into pages.
    • You can insert list of content.
  • Insert Spearly content into pages.
    • You can generate specified Spearly content as page.
  • Static Routing
    • You can use static routing feature that moving to content pages.

You can use live-mode as well. If you want to use it, you need to execute the following command:

spear watch -s <project directory>

Static Routing

spear-cli generate static site with Spearly CMS Content. The spec is as follow:

  • File name: /path/[alias].html
  • Generated File name: /path/<content-alias>.html (e.g., content alias is first-blog, file name is /path/first-blog.html)
  • Spearly Syntax: Same to spearly embed js v3. (For detail, see official document.)
  • You can create list pages by using spearly syntax as well.

Directory structures

spear-cli has directory rules:

  • components : top-level directory named `components'
    • There are spear components which inserting into pages or other component.
    • spear-cli allow nested directory structure. (E.g., /components/common, /components/cards)
    • spear-cli ignore the name which is same to HTML DOM tag name since preventing mixed native and component content. (e.g., body, header, section).
  • assets/public: top-level assets files directory named assets or public.
    • spear-cli output this directory without converting.
  • other directories: top-level directories any named.
    • spear-cli output this directory with html converting.
    • spear-cli keep directory structure.
    • If there are html/spear/htm file, spear-cli traverse and insert spear component.
    • If there are binary file, spear-cli output files as it is.

Example directories:

ā”œā”€ā”€ package.json
ā”œā”€ā”€ spear.config.json
└── src
    ā”œā”€ā”€ assets
    │   ā”œā”€ā”€ css
    │   │   └── main.css
    │   └── js
    │       └── main.js
    ā”œā”€ā”€ blog
    │   ā”œā”€ā”€ index.html
    │   └── [alias].html
    ā”œā”€ā”€ components
    │   ā”œā”€ā”€ header.spear
    │   └── main.spear
    ā”œā”€ā”€ images
    │   └── logo.png
    ā”œā”€ā”€ index.html
    ā”œā”€ā”€ pages
    │   └── index.spear
    └── public
        └── favicon.ico

After spear-cli build, an above example directory will be the following structure.

ā”œā”€ā”€ dist
│   ā”œā”€ā”€ assets
│   │   ā”œā”€ā”€ css
│   │   │   └── main.css
│   │   └── js
│   │       └── main.js
│   ā”œā”€ā”€ blog
│   │   ā”œā”€ā”€ index.html
│   │   ā”œā”€ā”€ first-blog.html
│   │   ā”œā”€ā”€ second-blog.html
│   │   ā”œā”€ā”€     :
│   │   └── second-blog.html
│   ā”œā”€ā”€ images
│   │   └── logo.png
│   ā”œā”€ā”€ pages
│   │   └── index.html
│   └── public
│       └── favicon.ico
ā”œā”€ā”€ package.json
ā”œā”€ā”€ spear.config.json

Note that:

  • components/header.spear and components/main.spear was inserted pages.
  • pages/index.spear renamed pages/index.html.

Building pages

At the last process, you can build all of them.

$ spear build -s <project directory>


Congrats! You can build your pages with Spearly šŸš€šŸš€šŸš€

## Resource

spear-cli has official document by using Spearly CMS.


## Contributing

If you want to contribute this project, You can read [CONTRIBUTING.md](./CONTRIBUTING.md) !  
We will wait for your participant!
1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.11

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago