1.0.19 ā€¢ Published 1 year ago

spear-cli v1.0.19

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.11

2 years ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago