多年前写过一个静态网站生成器,取名为 Pagic,如今有一些新的想法,正好赶上 Deno 发布,于是用 Deno 重写了一番,并添加了一些新 Feature 。
欢迎大家来试用~
# Install deno https://deno.land/#installation curl -fsSL https://deno.land/x/install/install.sh | sh # Install pagic deno install --unstable --allow-read --allow-write --allow-net https://raw.githubusercontent.com/xcatliu/pagic/master/pagic.ts
目录结构如下:
docs/ ├── public/ └── src/ ├── _layout.tsx └── index.md
src/_layout.tsx
是一个简单的 React 组件:
// @deno-types="https://deno.land/x/types/react/v16.13.1/react.d.ts" import React from 'https://dev.jspm.io/[email protected]'; import { PagicLayout } from 'https://raw.githubusercontent.com/xcatliu/pagic/master/pagic.ts'; const Layout: PagicLayout = ({ title, content }) => ( <html> <head> <title>{title}</title> <meta charSet="utf-8" /> </head> <body>{content}</body> </html> ); export default Layout;
src/index.md
是一个简单的 markdown 文件
# Pagic The easiest way to generate static html page from markdown, built with Deno!
运行:
pagic build
我们将会得到一个 public/index.html
文件:
docs/ ├── public/ | └── index.html └── src/ ├── _layout.tsx └── index.md
它的内容是:
<html> <head> <title>Pagic</title> <meta charset="utf-8" /> </head> <body> <article> <h1 id="pagic">Pagic</h1> <p>The easiest way to generate static html page from markdown, built with Deno! </p> </article> </body> </html>
其他特性请到 GitHub 上查看。
Deno 本身很好用,但生态十分缺失,我踩了无数个坑才完成了第一个版本,以后再写个文章细说。
1 myd 2020-05-21 19:34:29 +08:00 赞一个,继续加油 |
![]() | 2 mathzhaoliang 2020-05-21 20:31:43 +08:00 支持调用 pandoc 外部渲染吗 |
![]() | 3 ares586 2020-05-22 10:06:20 +08:00 冲着敢用 Deno,赞一个 |
![]() | 4 xcatliu |
![]() | 5 mathzhaoliang 2020-05-22 15:16:00 +08:00 @xcatliu 要是不支持 pandoc 渲染的话,mathjax 就几乎没法用,这个主题就只能写写日记了。 |
![]() | 6 xcatliu OP @mathzhaoliang 支持 plugins,可以随意修改构建流程,目前有三个 plugins - md: 解析 *.md 文件,content 设置为一个 ReactElement - tsx: 解析 *.tsx 文件,content 设置为一个 ReactElement - layout: 将 content 包装一层 <Layout> 可以随意组装、删除、添加 plugins 所以应该能支持,不过可能得自己写 plugin |
![]() | 7 longjiahui 2020-05-23 15:08:34 +08:00 deno logo 过于可爱 |
![]() | 8 cai314494687 2020-05-24 11:39:59 +08:00 ![]() 没有 demo ? |
![]() | 9 F7ionsy 2020-05-27 19:47:29 +08:00 via iPhone 写了好几个 hexo 主题,已经不想迁移了,成本太高 |
![]() | 10 xcatliu OP |