• Stars
    star
    2,897
  • Rank 15,667 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Transform Markdown(and other static files with transformers) into a SPA website using React.

Bi Sheng

Build status npm package NPM downloads Dependency Status

Bi Sheng was the Chinese inventor of the first known movable type technology.

bisheng is designed to transform Markdown(and other static files with transformers) into static websites and blogs using React.

Sites built with BiSheng

You can create a PR to extend this list with your amazing website which is built with BiSheng.

Features

bisheng is based on dora & webpack & React & react-router, and it has the following features:

Big picture

Big picture of BiSheng

Articles

Usage

Installation:

npm install --save-dev bisheng

Then, add start to npm scripts:

{
  "scripts": {
    "start": "bisheng start"
  }
}

Create bisheng.config.js, otherwise bisheng will use the default config:

module.exports = {
  source: './posts',
  output: './_site',
  theme: './_theme',
  port: 8000,
};

Note: please make sure that source and theme exists, and theme should not be an empty directory. Just use bisheng-theme-one, if you don't know how to develop a theme. See a simple demo here.

Now, just run npm start.

Documentation

CLI

We can install bisheng as a cli command and explore what it can do by bisheng -h. However, the recommended way to use bisheng is to install it as devDependencies.

$ npm install -g bisheng
$ bisheng -h
  Usage: bisheng [command] [options]

  Commands:

    start [options]     to start a server
    build [options]     to build and write static files to `config.output`
    gh-pages [options]  to deploy website to gh-pages
    help [cmd]          display help for [cmd]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

Configuration

bisheng will read bisheng.config.js as its config file, but we can set the config file name by --config, something like this bisheng --config another.config.js.

The content of bisheng.config.js looks like this:

module.exports = {
  port: 8000,
  source: './posts',
  output: './_site',
  theme: './_theme',
  htmlTemplate: path.join(__dirname, '../template.html'),
  devServerConfig: {},
  webpackConfig(config) {
    return config;
  },
  hash: false,

  entryName: 'index',
  root: '/',
};

port: Number

default: 8000

To set the port which will be listened when we start a local server.

source: String | Array[String] | Object{ [category]: String | Array[String]}

default: './posts'

To set directory/directories where we place Markdown files.

And all the Markdown files in source will be parsed and then structured as a tree data, for example:

posts
โ””โ”€โ”€ dir1
  โ”œโ”€โ”€ a.md
  โ””โ”€โ”€ b.md

Will output a Markdown data tree:

{
  dir1: {
    a: {...},
    b: {...},
  },
}

And each Markdown file will be parsed as a Markdown data. Actually, a Markdown data is the returned value of mark-twain, and it could be preprocessed by plugins.

exclude: RegExp

default: null

If you want to exclude some files in your source, just use exclude. Then bisheng will not parse files which match exclude.

output: String

default: './_site'

To set directory where bisheng will generate (HTML & CSS & JavaScript) files to.

theme: String

default: './_theme'

To set directory where we put the theme of website, and it also can be a npm package name.

More about theme.

themeConfig: any

undefined

A set of configuration that your theme provides, and then your theme can read it from props.themeConfig.

Note: themeConfig will be JSON.stringify before it's passed to props, so you cannot pass function/RegExp through themeConfig.

htmlTemplate: String

default: bisheng/lib/template.html

The HTML template which will be use to generate HTML files which will be sent to users.

Note: template will be parsed by nunjucks, and you can use the following variables in this template:

htmlTemplateExtraData: Object

default: {}

The Extra Data which will be used to render htmlTemplate.

devServerConfig: Object

default: {}

You can consult webpack-dev-server's documentation.

postcssConfig: Object

default: {
    plugins: [
      rucksack(),
      autoprefixer({
        browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 8', 'iOS >= 8', 'Android >= 4'],
      }),
    ],
  }

You can consult webpack postcss-loader's documentation.

webpackConfig: (config) => config

default: (config) => config

To modify the webpack config, you can extend the config like this.

transformers: Object[]

[{ test: /.md$/, use: MarkdownTransformer }]

A list of transformers that will be used to transform static files.

entryName: String

default: 'index'

The name of files which will be generated by webpack, such as [entryName].js & [entryName].css.

root: String

default: '/'

If the website will be deployed under a sub-directory of a domain (something like http://benjycui.github.io/bisheng-theme-one/), we must set it (such as /bisheng-theme-one/).

License

MIT

More Repositories

1

introrx-chinese-edition

The introduction to Reactive Programming you've been missing -- ไธญๆ–‡็‰ˆ
774
star
2

omit.js

Utility function to create a shallow copy of an object which had dropped some fields.
JavaScript
176
star
3

mark-twain

Parse Markdown into JavaScript object.
JavaScript
89
star
4

benjycui.github.io

HTML
47
star
5

jsonml-to-react-element

To convert JsonML to React element.
JavaScript
41
star
6

react-github-button

Unofficial GitHub buttons in React.
CSS
39
star
7

exist.js

To make it easier to access nested property
JavaScript
31
star
8

dekko

To test whether files and directory structure are valid with jQuery-like APIs.
JavaScript
25
star
9

node-prismjs

An adapter which make it easier to use Prism in Node.js.
JavaScript
24
star
10

react-sublime-video

A sublime video player in React.
JavaScript
24
star
11

future-ui

A list of ideas that may be useful while developing a React UI library.
12
star
12

jsonml.js

JsonML-related tools for losslessly converting between XML/HTML and JSON, including mixed-mode XML. http://jsonml.org
JavaScript
11
star
13

bisheng-theme-one

The one theme for bisheng.
10
star
14

eslint-tinker

To fix ESLint Errors in Markdown(or more in the future) automatically.
JavaScript
7
star
15

est

JavaScript is an out-of-box template engine.
7
star
16

bisheng-plugin-react

To convert JSX which is written in Markdown to React.Element.
7
star
17

selector-specificity

A calculator for CSS selector's specificity.
JavaScript
6
star
18

visit.js

To make it easier to access nested property
JavaScript
4
star
19

bisheng-plugin-description

To extract description from Markdown.
3
star
20

roses

A red rose is an unmistakable expression of love.
JavaScript
3
star
21

open-source-hero

A CLI tool to get how many repositories a user had contributed to.
JavaScript
3
star
22

bisheng-plugin-toc

Generate a Table of Contents (TOC) for Markdown files.
2
star
23

dzh-react-native-cli

ๅคงไธญๅŽ็‰ˆ react-native-cli๏ผŒไฝฟ็”จ cnpm ๅŠ ๅฟซไพ่ต–ๅฎ‰่ฃ…้€Ÿๅบฆใ€‚
JavaScript
2
star
24

react-probe

Utilities to test React components' methods directly.
JavaScript
2
star