Coder Social home page Coder Social logo

quickpage's Introduction

quickpage

快速生成静态HTML的整站程序,代码来源于 jsxss.com,帮助开源项目作者简单快速地制作项目主页

创建初始项目

quickpage create [源码目录]

启动开发环境

quickpage start [源码目录]

生成静态页面

quickpage build [源码目录] [目标目录]

使用方法

配置路由

文件 routes.js

module.exports = function (page) {

  ['zh', 'en'].forEach(function (lang) {
  
    // 载入配置
    var config = page.load(lang + '/config');
  
    // 访问/about.html时显示页面about.liquid
    page.add(lang + '/about', lang + '/about.liquid', config);
  
    // 访问/help.html时显示页面help.md
    page.add(lang + '/help', lang + '/help.md', config);
    
  });

};

page.load(name)

载入指定文件(省略后缀,后缀可以为.js.json

page.add(pathname, filename, config)

添加页面

  • pathname为访问路径,会自动加上.html后缀;
  • filename为源文件,如果是.html后缀表示Liquid模板文件,如果为.md后缀表示Markdown文件,会先将其转成HTML代码,并存储到content变量,然后渲染模板markdown

page.engine(extname, handler)

设置处理指定后缀文件的渲染方法

var md = require('markdown-it')();

page.engine('md', function (filename, callback) {
  // filename表示文件名
  // callback为回调函数

  fs.readFile(filename, function (err, content) {
    if (err) return callback(err);
    
    // template为用于显示的模板
    // content为内容
    callback(null, {
      template: 'markdown',
      content: md.render(content)
    });
  });
});

quickpage's People

Contributors

leizongmin avatar

Watchers

 avatar  avatar  avatar

Forkers

jyxtsgx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.