V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
xcatliu
V2EX  ›  分享创造

最简单的静态网站生成器 Pagic v0.5.0,修复 watch 的问题,添加 watch(), unwatch() 方法

  •  1
     
  •   xcatliu ·
    xcatliu · 2017-03-14 21:42:30 +08:00 · 1924 次点击
    这是一个创建于 2599 天前的主题,其中的信息可能已经有所发展或是发生改变。

    GitHub: https://github.com/xcatliu/pagic


    最简单的静态网站生成器 Pagic 发布 v0.5.0 啦!

    The easiest way to generate static html page from markdown

    修复了 watch 的问题

    现在不会修改任一文件就全部 rebuild 了。

    而是会根据修改的文件类型选择尽可能少的 rebuild 方式。

    比如修改 xxx.md 文件,则只 rebuild 这一个文件。如果修改了 _layout.js 则会 rebuild 它的子目录下所有文件。

    watch(), unwatch() 方法

    pagic.watch().build();
    
    setTimeout(() => {
      pagic.unwatch();
    }, 10000);
    

    GitHub 上的测试覆盖率

    写了很多单元测试,所以总结了一个测试覆盖率的文章,GitHub 上的测试覆盖率

    快来试试吧!

    npm install pagic -g
    
    pagic init new_site
    
    cd new_site
    pagic build
    

    感谢 tracker1 shellphon hustcc shellphon 等人的建议和帮助!


    以下是给不了解 Pagic 的人看的简单介绍。


    特性

    • 极简的使用方式:只需要 xxx.md_layout.js 即可
    • 其他静态资源文件直接复制到 public 文件夹
    • 支持 sub page 和 sub layout ,每个 Markdown 文件会一级一级往上查找,选择最近的 _layout.js 作为模板
    • 传入 relativeToRoot 到模板中,方便插入静态资源如 css
    • 支持 cli 和 node modules 引入

    Links

    6 条回复    2017-04-03 17:33:19 +08:00
    Yourdaye
        1
    Yourdaye  
       2017-03-14 21:59:55 +08:00 via iPhone   ❤️ 1
    最好能给个 demo
    xcatliu
        2
    xcatliu  
    OP
       2017-03-14 22:04:01 +08:00
    @Yourdaye 只是个静态网站生成器, css 需要自己写,我没有内置默认的 css 。

    这儿有个 demo : http://xcatliu.com/pagic/

    这个也是用 Pagic 生成的: https://mobi-css.github.io/mobi-plugin-flexbox/
    ifreego
        3
    ifreego  
       2017-03-15 06:49:00 +08:00
    你这个需要自己写 css 啊。我觉得很多人用 hexo,jekyll 啊,都是冲着 themes 去的 -_-||
    bztd001
        4
    bztd001  
       2017-03-31 12:44:54 +08:00   ❤️ 1
    index.md

    ```
    # Pagic

    The 简单 way to generate static html page from markdown

    ## Pages

    - [css/site.css](css/site.css)
    - [sub](sub)
    - [sub/sub_sub](sub/sub_sub)
    - [front_matter](front_matter)
    - [relative_to_root](relative_to_root)
    - [relative_to_root/sub](relative_to_root/sub)

    ```


    ***

    ```
    pagic build
    ```

    ***

    ![图片]( http://i1.piimg.com/1949/1e46bad55cb56255.png)


    ***

    如何操作才能使 index.md 中支持中文。。。。。。。
    xcatliu
        5
    xcatliu  
    OP
       2017-03-31 12:57:38 +08:00 via iPhone
    @bztd001 好像还真没测试过中文 😂,谢谢反馈,一会儿我看看
    xcatliu
        6
    xcatliu  
    OP
       2017-04-03 17:33:19 +08:00   ❤️ 1
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1375 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:46 · PVG 07:46 · LAX 16:46 · JFK 19:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.