- v1.6.3Latest
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- v1.0.0-alpha.4
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha.1
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.8
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.4
- v0.9.3
- v0.9.2
- v1.9.2
- v0.9.1
- v0.9.0
- v0.8.7
- v0.8.7
- v0.8.7
- v0.8.7
- v0.8.7
- v0.8.6
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.30
- v0.6.0
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.1
- v0.1.0
- 0.7.29
- 0.7.28
- 0.7.27
- 0.7.26
- 0.7.25
- 0.7.24
- 0.7.23
- 0.7.22
- 0.7.21
- 0.7.20
- 0.7.19
- 0.7.18
- 0.7.17
- 0.7.16
- 0.7.15
- 0.7.14
- 0.7.14-debug.1
- 0.7.13
- 0.7.12
- 0.7.11
- 0.7.10
- 0.7.9
- 0.7.8
- 0.7.7
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.7.0-debug.2
- 0.7.0-debug.1
Pagic
The easiest way to generate static html page from markdown, built with Deno! π¦
Features
- Markdown + Layout => HTML
- React component as a page
- Copy static files
- Sub pages and layouts
- Front matter
- Configuration
- Plugins and themes
WARNING: This project is under development so api would changes without announce. The stable version will some soon when v1.0.0 finished.
Live demo
- Deno X ranking (GitHub)
- TypeScript ε ₯ι¨ζη¨ (GitHub)
- Deno ι»η δΉζ― (GitHub)
- Deno δΈζζε (GitHub)
- Add my site as a demo π
Getting started
Installation
# 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 --name pagic https://deno.land/x/pagic@v0.8.6/mod.ts
Docker
alias pagic='docker run -it --rm -v $PWD:/pagic yardenshoham/pagic'
Markdown + Layout => HTML
Letβs say we have a project like this:
docs/
βββ public/
βββ src/
βββ _layout.tsx
βββ index.md
The src/_layout.tsx
is a simple react component:
// @deno-types="https://deno.land/x/pagic@v0.8.6/src/types/react/v16.13.1/react.d.ts"
import React from 'https://dev.jspm.io/react@16.13.1';
import { PagicLayout } from 'https://deno.land/x/pagic@v0.8.6/mod.ts';
const Layout: PagicLayout = ({ title, content }) => (
<html>
<head>
<title>{title}</title>
<meta charSet="utf-8" />
</head>
<body>{content}</body>
</html>
);
export default Layout;
The src/index.md
is a simple markdown file:
# Pagic
The easiest way to generate static html page from markdown, built with Deno! π¦
Then run:
pagic build
Weβll get an index.html
file in public
directory:
docs/
βββ public/
| βββ index.html
βββ src/
βββ _layout.tsx
βββ index.md
The content should be:
<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>
React component as a page
A react component can also be built to html:
docs/
βββ public/
| βββ index.html
| βββ hello.html
βββ src/
βββ _layout.tsx
βββ index.md
βββ hello.tsx
Here we build src/hello.tsx
to public/hello.html
, using src/_layout.tsx
as the layout.
src/hello.tsx
is a simple react component:
// @deno-types="https://deno.land/x/pagic@v0.8.6/src/types/react/v16.13.1/react.d.ts"
import React from 'https://dev.jspm.io/react@16.13.1';
const Hello = () => <h1>Hello World</h1>;
export default Hello;
And public/hello.html
would be:
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Copy static files
If there are other static files which are not end with .{md,tsx}
or (start with _
and end with .tsx
), we will simply copy them:
docs/
βββ public/
| βββ assets
| | βββ index.css
| βββ index.html
| βββ hello.html
βββ src/
βββ assets
| βββ index.css
βββ _layout.tsx
βββ _sidebar.tsx
βββ index.md
βββ hello.tsx
Sub pages and layouts
We can have sub directory which contains markdown or component.
Sub directory can also have a _layout.tsx
file.
For each markdown or react component, it will walk your file system looking for the nearest _layout.tsx
. It starts from the current directory and then moves to the parent directory until it finds the _layout.tsx
.
docs/
βββ public/
| βββ assets
| | βββ index.css
| βββ index.html
| βββ hello.html
| βββ sub
| βββ index.html
βββ src/
βββ assets
| βββ index.css
βββ _layout.tsx
βββ _sidebar.tsx
|ββ index.md
βββ sub
βββ _layout.tsx
βββ index.md
Front matter
Front matter allows us add extra meta data to markdown:
---
author: xcatliu
published: 2020-05-20
---
# Pagic
The easiest way to generate static html page from markdown, built with Deno! π¦
Every item in the front matter will pass to the _layout.tsx
as the props:
// @deno-types="https://deno.land/x/pagic@v0.8.6/src/types/react/v16.13.1/react.d.ts"
import React from 'https://dev.jspm.io/react@16.13.1';
import { PagicLayout } from 'https://deno.land/x/pagic@v0.8.6/mod.ts';
const Layout: PagicLayout = ({ title, content, author, published }) => (
<html>
<head>
<title>{title}</title>
<meta charSet="utf-8" />
</head>
<body>
{content}
<footer>
Author: ${author}, Published: ${published}
</footer>
</body>
</html>
);
export default Layout;
Front matter in react component
In react component we can export a frontMatter
variable:
// @deno-types="https://deno.land/x/pagic@v0.8.6/src/types/react/v16.13.1/react.d.ts"
import React from 'https://dev.jspm.io/react@16.13.1';
const Hello = () => <h1>Hello World</h1>;
export default Hello;
export const frontMatter = {
title: 'Hello World',
author: 'xcatliu',
published: '2020-05-20'
};
Configuration
Itβs able to configurate pagic by adding a pagic.config.ts
file. The default configuration is:
export default {
srcDir: '.',
outDir: 'dist',
include: undefined,
exclude: [
// Dot files
'**/.*',
// Node common files
'**/package.json',
'**/package-lock.json',
'**/node_modules',
'pagic.config.ts',
'pagic.config.tsx',
// https://docs.npmjs.com/using-npm/developers.html#keeping-files-out-of-your-package
'**/config.gypi',
'**/CVS',
'**/npm-debug.log'
// ${config.outDir} will be added later
],
root: '/',
theme: 'default',
plugins: ['clean', 'init', 'md', 'tsx', 'script', 'layout', 'out'],
watch: false,
serve: false,
port: 8000
};
Your pagic.config.ts
will be deep-merge to the default config, that is, your exclude
and plugins
will be appended to default, not replace it.
Plugins and themes
As you see default plugins are set to ['init', 'md', 'tsx', 'script', 'layout', 'write']
.
We can add the optional plugins by setting the plugins
in the pagic.config.ts
file:
export default {
srcDir: 'site',
plugins: ['sidebar']
};
sidebar
plugin will add a sidebar
properity to the props.
We can also add our own plugin like this:
import myPlugin from './myPlugin.tsx';
export default {
srcDir: 'site',
plugins: [myPlugin]
};
To develop a myPlugin
please checkout the built-in plugins.
Themes is under development, please come back later!
Use pagic as cli
pagic build
We can use pagic build
to build static pages, there are some options while using build
command:
pagic build [options]
# --watch watch src dir change
# --serve serve public dir
# --port override default port
LICENSE
Have fun with pagic!