0.2.1 • Published 7 years ago
diz v0.2.1
A static site generator.
Install
$ yarn add -D diz gulp
$ npm i -D diz gulp
Example
Diz.load({base: 'relative/path/'}).then(roots => {
const renderer = new Diz({roots});
// .html etc
renderer.render().pipe(gulp.dest('example/dist/'));
// .js using webpack
renderer.bundle().then(stream => {
stream.pipe(gulp.dest('example/dist/'));
});
});
File organization
The directory at the level one level below root path is recognized as root. However, in order to be processed, it is necessary to put config.js directly under the root directory.
└─ <base path>
│ // blog1 is processed
├─ <blog1>
│ ├─ 0_getting-started.md
│ ├─ 1_hello-world.md
│ ├─ n_***.md
│ ├─ config.js
│
│ // blog2 isn't processed because there is no config.js
├─ <blog2>
│ ├─ 0_getting-started.md
│ ├─ 1_hello-world.md
│ ├─ n_***.md
├─ <...>
In config.js
, describe meta information about the site, theme information, compilation method and so on. Also, the string up to _
in each .md file is removed. It just uses to adjust the order of post files.
For example, it will be like this.
const Renderer = require('diz-theme-xxxx');
const Plugin = require('diz-plugin-yyy');
const marked = require('marked');
module.exports = {
//* required
title: 'blog title',
url: 'http://blog.com/',
//* option
description: 'blog description',
author: 'nju33',
//* option
// Whether to reverse the order of n_*.md files
reverse: false
//* option
// When parent directory name is specified,
// the following happens
//
// 1. Inherit config.js of the specified directory
// 2. Becomes part of the blog of the specified directory
//
parent: '...'
//* option
// Overwrite inherited config
override: {...}
//* required
theme: {
//* required
// The theme itself (.jsx etc)
Renderer,
//* option
// Theme's config
config: {}
},
//* option
// Md file conversion function
// (contents: string): string
compile: marked,
//* option
// Array of used plugins
plugins: [new Plugin()]
};
The config data changes depending on the plugin and theme you are using.
CLI
diz generate id
diz generate date
Themes
How to create a theme
- Install diz-theme
- use it in parent class (e.g.)
class extends DizTheme
For more information, click here
Plugins
License
The MIT License (MIT)
Copyright (c) 2016 nju33 nju33.ki@gmail.com