Installations
npm install @spearly/spear-cli
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
18.18.1
NPM Version
9.8.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (96.47%)
HTML (1.61%)
JavaScript (1.59%)
SCSS (0.33%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
Download Statistics
Total Downloads
11,406
Last Day
1
Last Week
1
Last Month
56
Last Year
2,392
GitHub Statistics
MIT License
10 Stars
200 Commits
1 Forks
7 Watchers
9 Branches
13 Contributors
Updated on May 23, 2024
Bundle Size
4.92 MB
Minified
1.21 MB
Minified + Gzipped
Package Meta Information
Latest Version
1.4.13
Package Id
@spearly/spear-cli@1.4.13
Unpacked Size
215.70 kB
Size
56.38 kB
File Count
44
NPM Version
9.8.1
Node Version
18.18.1
Published on
Dec 21, 2023
Total Downloads
Cumulative downloads
Total Downloads
11,406
Last Day
0%
1
Compared to previous day
Last Week
0%
1
Compared to previous week
Last Month
-48.6%
56
Compared to previous month
Last Year
-70.1%
2,392
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
16
spear-cli
Note:
- v1.3.2 is disabling the SCSS feature because some build toolchanin has build error.(Vite)
This is SSG(Static Site Generator) for Spearly.
Usage
Create project
As first step, you need to create:
npm create spear@latest
: This command start wizard creating project.
1Namespace(port=undefined, action='create', projectName=undefined, src=undefined) 2 ### Welcome to Spear CLI ### 3 4 5? Name of your project (spear-cli) <Input your project name> 6? Use Spearly CMS (Use arrow keys) 7❯ Yes <- Choose 'yes' if you use the Spear content. 8 No 9? Enter your Spearly CMS API KEY <Input your Spearly API KEY> 10? Choose template type (Use arrow keys) 11❯ basic 12 empty 13? Generate Sitemap? 14❯ Yes 15 No 16 ? Enter your hosting URL (Example: https://foobar.netlify.app/) () 17 18 19? Name of your project SampleProject 20? Use Spearly CMS Yes 21? Enter your Spearly CMS API KEY ********** 22 23 ## Your project was created 🎉 24 25 To start using, run the following command: 26 cd SampleProject 27 yarn install 28 29 To start local server, run 30 yarn dev 31 32 To build static sources, run 33 yarn build 34
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
.
- You can create parts of pages as
- 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:
1spear 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 isfirst-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.
SASS
spear-clil
supports SASS syntax. All of scss
files under the src
is compiled, and spear will copy compiled css file to relative path under dist
.
Sitemap generation
spear-cli
will generate sitemap automatically if you set the sitemap configuration into config file.
This feature requires the flag of the site generating and host URL. You can specify these values in spear.config.js
file.
1 "generateSitemap": boolean, 2 "siteURL": string,
SEO Tag
Spear will inject the SEO related tag into generated file if you configure the SEO Tag setting.
If you want to use SEO feature, you need to plugin into spear.config.mjs
file.
1import { spearSEO } from "@spearly/spear-cli/dist/plugins/spear-seo.js" 2export default { 3 ... 4 plugins: [ 5 spearSEO(), 6 ] 7}
After you set above setting, Spear will inject SEO related tag automatically.
1<spear-seo 2 title="Page title" 3 meta-description="Page description" 4 meta-og:url="/pics/ogp.png"> 5</spear-seo>
Available attribute for SEO is the following:
Attribute | Description | Generated Value |
---|---|---|
title | Site title | |
meta-*** | Meta information | |
link-*** | Link description |
i18n (Internationalization)
You can localize your site with i18n plugin if you have international site.
If you want to use it, you need to configure plugin setting into spear.config.mjs
.
1import { spearI18n } from "@spearly/spear-cli/dist/plugins/spear-i18n.js" 2export default { 3 ... 4 plugins: [ 5 spearI18n('./i18n.yaml') 6 ] 7}
The language file is requirement for using i18n. Language file is consist of key and value.
1settings: 2 default: "jp" 3lang: 4 jp: 5 - title: ブログだよ 6 - description: ブログサイトです 7 - url: https://www.yahoo.co.jp 8 en: 9 - title: Blog 10 - description: This is blog site. 11 - url: https://www.google.com
Spear provide the two way for using localization feature:
- i18n Attributes
Spear will replace the all child node to localized string if there are HTML Tags which has i18n.
Example:
1<p i18n="title"></p> 2<!-- Replaced the bellow in Japanese --> 3<p>ブログだよ</p>
- Embed syntax (
{%= translate() %}
)
Spear will replace the embed syntax as well.
1<title>{%= translate('title') %}</title> 2<!-- Replaced the bellow in Japanese --> 3<title>ブログだよ</title>
You can specify t()
instead of translate()
.
Spear provide the two way for using localization link feature as well:
- spear-link Tag
Spear will replace the specified URL of spear-link
tag to each language.
1<spear-link href="/about.html">About us</spear-link> 2<!-- Replaced the bellow in Japanese --> 3<a href="/ja/about.html">About us</a>
- Embed Syntax (
{%= localize() %}
)
Spear will replace the URL of embed syntax to each language.
1<script> 2 function click() { 3 window.location = "{%= localize('./about.html') %}" 4 } 5</script> 6<!-- Replaced the bellow in Japanese --> 7<script> 8 function click() { 9 window.location = "ja/about.html" 10 } 11</script>
Note that:
- Generated URL path will change by original specified path.(Absolute path and relative path.)
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
orpublic
.- 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:
1├── package.json 2├── spear.config.json 3└── src 4 ├── assets 5 │ ├── css 6 │ │ └── main.css 7 │ └── js 8 │ └── main.js 9 ├── blog 10 │ ├── index.html 11 │ └── [alias].html 12 ├── components 13 │ ├── header.spear 14 │ └── main.spear 15 ├── images 16 │ └── logo.png 17 ├── index.html 18 ├── pages 19 │ └── index.spear 20 └── public 21 └── favicon.ico
After spear-cli build, an above example directory will be the following structure.
1├── dist 2│ ├── assets 3│ │ ├── css 4│ │ │ └── main.css 5│ │ └── js 6│ │ └── main.js 7│ ├── blog 8│ │ ├── index.html 9│ │ ├── first-blog.html 10│ │ ├── second-blog.html 11│ │ ├── : 12│ │ └── second-blog.html 13│ ├── images 14│ │ └── logo.png 15│ ├── pages 16│ │ └── index.html 17│ └── public 18│ └── favicon.ico 19├── package.json 20├── spear.config.json
Note that:
components/header.spear
andcomponents/main.spear
was inserted pages.pages/index.spear
renamedpages/index.html
.
Building pages
At the last process, you can build all of them.
1$ spear build -s <project directory>
Congrats! You can build your pages with Spearly 🚀🚀🚀
Configuration File
Spear build according to spear.config.js
. This file has the following settings:
1module.exports = { 2 "spearlyAuthKey": string, // Specify the spearly api token for fetching. 3 "projectName": string, // This project name. 4 "generateSitemap": boolean, // Whether generating the sitemap or not. 5 "siteURL": string, // Base URL of generation sitemap. (optional) 6 "apiDomain": string, // Fetching API Domain. (optional) 7};
Editor settings
Spear is a editor free tool. However, you can use the following settings to have a better experience when coding in your favorite editor.
Visual Studio Code
A default settings is created at .vscode/settings.json
for better highlighting of the code, specially .spear
files.
JetBrains(IntelliJ, WebStorm, PhpStorm, etc)
While IntelliJ Plugin is under construction, there is a workaround for the editor to highlight .spear
files at Configure associations between filename patterns and file types
Contributing
If you want to contribute this project, You can read CONTRIBUTING.md !
We will wait for your participant!

No vulnerabilities found.

No security vulnerabilities found.