# genghis

> A static blogging engine. Build a blog with more controls in a single setting.

Latest version **0.1.8** (published 2015-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install genghis
pnpm add genghis
yarn add genghis
bun add genghis
```

Provides the command `genghis`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2015-08-11 |
| First published | 2015-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | chilijung |
| Maintainers | chilijung |
| Keywords | canner, blog, genghis |

## Links

- npm: https://www.npmjs.com/package/genghis
- npm.io page: https://npm.io/package/genghis

## Dependencies (6)

- [q](https://npm.io/package/q.md) ^1.4.1
- [q-io](https://npm.io/package/q-io.md) ^1.13.1
- [lodash](https://npm.io/package/lodash.md) ^3.10.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^0.22.1
- [minimist](https://npm.io/package/minimist.md) ^1.1.2
- [canner-core](https://npm.io/package/canner-core.md) 0.0.7

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.1.8 (latest) — 2015-08-11
- 0.1.7 — 2015-08-09
- 0.1.6 — 2015-08-08
- 0.1.5 — 2015-08-07
- 0.1.4 — 2015-08-07
- 0.1.3 — 2015-08-07
- 0.1.2 — 2015-08-07
- 0.1.1 — 2015-08-07
- 0.1.0 — 2015-08-05
- 0.0.1 — 2015-08-05
- 0.0.0 — 2015-08-05

## README

# genghis

A static blogging engine. Build a blog with more controls in a single setting.

![Image of genghis](https://raw.githubusercontent.com/Genghis-canner/genghis/master/images/genghis.png)

## Why?

There are lots of blogging engine already, most of them are great working if you want to build a general and simple blog. But for some cases, it was not that easy to configure. Such as if you want to change your posts' routes from `/posts/` to `/blog/post`, or tags' routes from `/tags/` to `/blog/tags` it was hard to change.

`genghis` not only make the whole blog's routes flexible, and also make the whole configuration in one place, which means you only need to setup your blog in a `.json` file. Sounds cool?! :)

## Table of Content

- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Sample](#sample)
- [Blog](#blog)
  - [Structure](#structure)
- [Settings](#settings)
  - [Post Settings](#post-settings)
  - [Posts](#posts)
  - [Categories](#categories)
  - [Tags](#tags)
  - [Author](#author)

## Install

Install genghis cli tool to global.

```
npm install -g genghis
```

Install npm module

```
npm install genghis
```

## Usage

#### build blog

##### options

- `-w`: watching files, if `hbs` changes `genghis` will rebuild files.

```
$ genghis ./blog.json -w
```

## API

#### build

build blog API

```js
genghis.build(json_file_path)
      .then(function(){
          // do your stuff
      })
      .catch(function(err){
          // deal with error
      });
```

#### watch

watch blog API

```js
genghis.build(json_file_path, true)
      .then(function() {
        // do things
      })
      .catch(function(err) {
        // do things
      })
```

## Sample

Here is a sample configure file [blog-multi.json](https://github.com/Canner/genghis/blob/master/test/blog-multi.json)

## Blog

#### Structure

Your setting structure of the blog.

`blog.json`:

```js
{
  // categories (optional)
  "categories": {
    ... (see categories section for more information)
  },
  // tags (optional)
  "tags": {
    ... (see tags section for more information)
  },
  // author (optional)
  "author": {
    ...  (see author section for more information)
  },
  // necessary
  "post_settings" {
    ... (see post settings section for more information)
  },
  // necessary
  "posts": [
    ... Array (see posts section for more information )
  ]
}
```

## Settings

#### post settings

Setting your post's layout and where the post's root folder, add a key named `post_settings`, set your `layout`, `path` inside. Every posts will render through the layout, and generate to the path in the path setting.

e.g.

```js
"post_settings": {
  // hbs helpers, partials, see settings in helpers and partial sections (optional)
  "helpers": ["./blog/helper.js"],
  "partials" ["./blog/partials"],
  "layout": "./blog/post.hbs",
  "path": "./opendata/post/"
},
```

#### posts

Create a new post. 

**Setting `date`, `url_name` are necessary.**

##### Main settings

- date: **date's format should be like %Y/%m/%d %H:%M:%S** this is very important. Because the date is used to render a specific post result.  For example, if you set the post settings' path to `"path": "./opendata/post/"` and your date `"date": "2015/08/03 22:07:39"`, `genghis` will build your post in directory `./opendata/post/2015/08/03/your-post-name.html` 

- url_name: Defines your post file name. From the example above it defines `./opendata/post/2015/08/03/<url_name>.html`.


e.g.

```js
"posts": [{
  "title": "This is a test post",
  // date format should be like %Y/%m/%d %H:%M:%S
  "date": "2015/08/03 22:07:39",
  "categories": ["opendata", "visualization"],
  "tags": ["taiwan", "health"],
  "cover": "http://i.imgur.com/o6llC95.jpg",
  "content": "./blog/test_post.md",
  // what your post html file called
  "url_name": "test-post",
  "author": "taiwanstat"
}]
```

#### Categories

Create categories in your blog.

##### Main settings

**Setting `layout`, `path`, `items` are necessary.**
  
  - layout: `genghis` will generate all the categories using the layout.
  - path: path is the root of the category folders. For instance, `"path": "./opendata/categories"` means it will generate `./opendata/categories/category1/`, `./opendata/categories/category2/`, ...
  - items: This is where you defined your categories. The sample below means this blog have `opendata`, `visualization` categories. And every variables defines in it will pass to your hbs template while rendering.

e.g.

```js
// categories (optional)
"categories": {
  // hbs helpers, partials, see settings in helpers and partial sections (optional)
  "helpers": ["./blog/helper.js"],
  "partials" ["./blog/partials"],
  "layout": "./blog/categories.hbs",
  "path": "./opendata/categories",
  "items": {
    // your categories settings
    "opendata": {
      "description": "this is a opendata categories",
      "others": "you can put your other variables here"
    },
    "visualization": {
      "description": "this is a visualization categories",
      "others": "you can put your other variables here"
    }
  }
}
```

#### Tags

Create tags in your blog.

##### Main settings

**Setting `layout`, `path`, `items` are necessary.**
  
  - layout: `genghis` will generate all the tags using the layout.
  - path: path is the root of the tag folders. For instance, `"path": "./opendata/tags"` means it will generate `./opendata/tags/tag1/`, `./opendata/tag/tag2/`, ...
  - items: This is where you defined your tags. The sample below means this blog have `weather`, `blog`, `health`, `taiwan` tags. And every variables defines in it will pass to your hbs template while rendering.

e.g.

```js
// tags (optional)
"tags": {
  // hbs helpers, partials, see settings in helpers and partial sections (optional)
  "helpers": ["./blog/helper.js"],
  "partials" ["./blog/partials"],
  "layout": "./blog/tags.hbs",
  "path": "./opendata/tags/",
  "items": {
    // your tags settings
    "weather": {
      "description": "this is a weather tag",
      "others": "you can put your other variables here"
    },
    "blog": {
      "description": "this is a blog tag",
      "others": "you can put your other variables here"
    },
    "health": {
      "description": "this is a health tag",
      "others": "you can put your other variables here"
    },
    "taiwan": {
      "description": "this is a taiwan tag",
      "others": "you can put your other variables here",
      "others2": "you can put your other variables here"
    }
  }
}
```

#### Author

Create Author list

##### Main settings

**Setting `layout`, `path`, `items` are necessary.**
  
  - layout: `genghis` will generate all the author using the layout.
  - path: path is the root of the author folders. For instance, `"path": "./opendata/author"` means it will generate `./opendata/author/taiwanstat/`, `./opendata/author/chilijung/`, ...
  - items: This is where you defined your author. The sample below means this blog have `taiwanstat`, `chilijung` author. And every variables defines in it will pass to your hbs template while rendering.

e.g.

```js
"author": {
  // hbs helpers, partials, see settings in helpers and partial sections (optional)
  "helpers": ["./blog/helper.js"],
  "partials" ["./blog/partials"],
  "layout": "./blog/author.hbs",
  "path": "./opendata/author",
  "items": {
    "taiwanstat": {
      "email": "test@gmail.com",
      "nickname": "taiwanstat"
    },
    "chilijung": {
      "email": "chilijung@test.com",
      "nickname": "chilijung"
    }
  }
},
```

##### helpers and partials

Setting up helpers and partials in hbs, see [canner helpers](https://github.com/Canner/canner#hbs-helpers) and [canner partials](https://github.com/Canner/canner#hbs-partials)

## TODO

- init blog, append posts
- create new tags, authors, categories in cli

## License

MIT

---
_Source: https://npm.io/package/genghis · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
