Skip to content

Commit

Permalink
add node package commander
Browse files Browse the repository at this point in the history
  • Loading branch information
niltor committed Jul 31, 2024
1 parent 9bf870a commit ff6cc14
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
with:
dotnet-version: 8.x

- run: dotnet tool install -g Ater.EasyBlog --version 1.0.0-beta1
- run: dotnet tool install -g Ater.EasyBlog --version 1.0.0
- run: ezblog build ./Content ./_site

- name: Upload artifact
Expand Down
2 changes: 1 addition & 1 deletion README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
with:
dotnet-version: 8.x

- run: dotnet tool install -g Ater.EasyBlog --version 1.0.0-beta1
- run: dotnet tool install -g Ater.EasyBlog --version 1.0.0
- run: ezblog build ./Content ./_site

- name: Upload artifact
Expand Down
6 changes: 6 additions & 0 deletions src/NodePackage/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/bin/*.d.ts
/bin/*.pdb
/bin/*.xml
/obj
*.csproj
*.sln
64 changes: 64 additions & 0 deletions src/NodePackage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Blog

This tool generates a `pure static` blog website from a `markdown` document through commands. With the help of `GitHub Pages`, you can have a personal blog for free in 5 minutes.It has the following characteristics

- Provide command line tools to generate static websites
- Generate a pure static website with extremely fast access speed
- Support for content written in markdown format
- Support search, classification, archiving and screening
- Customize website name and description, etc

**Demo:** NilTor's Blog: [https://blog.dusi.dev/](https://blog.dusi.dev/)

## 🎖️Features

- Blog list on the homepage, supporting search, category and archive filtering
- Customize website name and description
- Light and Dark themes that change with the system
- Adaptive display for mobile devices
- TOC support
- mermaid, nomnoml, Math rendering support
- Code highlighting and copy support

## 🚀Quick Start

Currently, the tool has been released in the form of 'dotnet tool'.You can easily install and use it.

### Using tools

We assume that you already have some markdown documents in the `markdown` directory.

Now we use the command:

```pwsh
ezblog init
```

Initialize a 'webinfo.json' file to configure the basic information of your blog. This file can be reused during subsequent generation.The document reads as follows:

```json
{
"Name": "Niltor Blog", // blog name, displayed at the top of the homepage navigation
"Description": "🗽 for freedom",// description, displayed in the middle of the top of the homepage
"AuthorName": "Ater", // Author name, displayed in the blog list
"BaseHref": "/blazor-blog/", // sub directory
"Domain": "https://aterdev.github.io" // Domain name, used for generating a sitemap. Leave it blank if not needed
}
```

> [!IMPORTANT]
Please note that the trailing `/` in `BaseHref` is mandatory.
>
If you have configured a custom domain name and are not using a subdirectory, set BaseHref to '/'.

Then we use the command

```pwsh
ezblog build .\markdown .\WebApp
```

This command will convert all markdown files in the 'markdown' directory into html files and generate them into the 'WebApp' directory.

You can use the `http-server` command to start a local server and view the generated content.

The 'WebApp' directory contains everything you need for a static website, and you can freely deploy it wherever you need.
34 changes: 34 additions & 0 deletions src/NodePackage/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
#!/usr/bin/env node
import dotnet from 'node-api-dotnet';
import { Command } from "commander";


const program = new Command();

program.name('ezblog')
.description('Generates a pure static blog website from a markdown document');

program.command('init')
.description('')
.action(() => {
console.log('init');
});


program.command('build <source> <output>')
.description('生成静态博客站点')
.argument('<source>', 'markdown文件目录')
.argument('<output>', '站点输出目录')
.action((source, output) => {

});

program
.action(() => {
console.log('No command provided. Use --help to see available commands.');
});

program.on('--help', () => {
console.log('Generates a pure static blog website from a markdown document');
});

program.parse(process.argv);
15 changes: 14 additions & 1 deletion src/NodePackage/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"name": "ater.ezblog",
"version": "0.1.0",
"bin": {
"ezblog": "./index.js"
},
"description": "Generates a pure static blog website from a markdown document through commands",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/AterDev/EasyBlog"
},
"homepage": "https://github.com/AterDev/EasyBlog",
"readme": "README.md",
"author": "NilTor",
"license": "MIT"
"license": "MIT",
"dependencies": {
"commander": "^12.1.0",
"node-api-dotnet": "^0.7.34"
}
}
31 changes: 31 additions & 0 deletions src/NodePackage/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff6cc14

Please sign in to comment.