Gathering detailed insights and metrics for @spearly/spear-cli
Gathering detailed insights and metrics for @spearly/spear-cli
Gathering detailed insights and metrics for @spearly/spear-cli
Gathering detailed insights and metrics for @spearly/spear-cli
npm install @spearly/spear-cli
Typescript
Module System
Node Version
NPM Version
TypeScript (96.47%)
HTML (1.61%)
JavaScript (1.59%)
SCSS (0.33%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
205 Commits
1 Forks
7 Watchers
9 Branches
14 Contributors
Updated on Mar 13, 2025
Latest Version
1.4.14
Package Id
@spearly/spear-cli@1.4.14
Unpacked Size
376.50 kB
Size
121.98 kB
File Count
46
NPM Version
9.8.1
Node Version
18.18.0
Published on
Mar 13, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
16
Note:
This is SSG(Static Site Generator) for Spearly.
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.
You can edit pages to you prefer. spear-cli support some features:
components
.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>
spear-cli
generate static site with Spearly CMS Content. The spec is as follow:
/path/[alias].html
/path/<content-alias>.html
(e.g., content alias is first-blog
, file name is /path/first-blog.html
)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
.
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,
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 |
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:
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>
{%= 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 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>
{%= 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:
spear-cli
has directory rules:
assets
or public
.
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
and components/main.spear
was inserted pages.pages/index.spear
renamed pages/index.html
.At the last process, you can build all of them.
1$ spear build -s <project directory>
Congrats! You can build your pages with Spearly 🚀🚀🚀
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};
Spear is a editor free tool. However, you can use the following settings to have a better experience when coding in your favorite editor.
A default settings is created at .vscode/settings.json
for better highlighting of the code, specially .spear
files.
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
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.