@abstractmachines/hotstuff 中文文档教程
hotstuff
可组合、增量、交钥匙文档编译器
阅读博客文章:AM010 - Hot Stuff
hotstuff is 交钥匙——它几乎不假设如何 您构建或编写您的内容。 也没有任何插件。
hotstuff 是可组合的 — 触摸现有文件夹中的几个文件 结构,它将正常工作。 接近零成本,您的内容始终是完整的 便携的。
hotstuff 是增量的——它积极地缓存你的项目,所以你 可以在数十万个文件上使用它。
只需一个命令:
- Cargo:
cargo install github.com/AbstractMachinesLab/hotstuff
- Yarn:
yarn global add @abstractmachines/hotstuff
- NPM:
npm install --global @abstractmachines/hotstuff
Getting Started
如果将 hotstuff-project
文件放在项目的根目录下,hotstuff 将 在整个项目中查找 site
文件。
site
文件告诉 hotstuff
这个特定的文件夹应该被编译 进入一个网站。
因此,如果您的帖子采用以下结构:
my/website λ tree
.
├── pages
│ ├── First-post.md
│ └── Some-other-post.md
└── sections
├── about.md
├── hire-me.md
└── projects.md
您只需要touch
几个文件:
my/website λ touch hotstuff-project
my/website λ touch pages/site sections/site
然后您可以运行hotstuff serve
来使用同一棵树编译网站 _public
文件夹下的结构,并通过热重载提供服务。
my/website λ hotstuff serve
11:19:09 INFO :: Building project...
11:19:09 INFO :: Built 9 artifacts in 6ms
11:19:09 INFO :: Done in 7ms
11:19:09 INFO :: Server listening on http://0.0.0.0:4000
现在您的文件结构如下所示:
my/website λ tree
.
├── _public
│ ├── pages
│ │ ├── First-post.html
│ │ └── Some-other-post.html
│ └── sections
│ ├── about.html
│ ├── hire-me.html
│ └── projects.html
├── hotstuff-project
├── pages
│ ├── First-post.md
│ ├── Some-other-post.md
│ └── site
└── sections
├── about.md
├── hire-me.md
├── projects.md
└── site
请注意,_public
文件夹已准备就绪,您可以随心所欲地使用它。 上传到 S3、Now、GCS、Github 页面或其他任何地方。
Installation
NPM
如果您已经在运行 npm
或 yarn
,您只需运行 yarn global add @abstractmachines/hotstuff
或 npm install -g @abstractmachines/hotstuff
到 在您的计算机中获取正确的二进制文件。
如果您针对 Github 包注册表运行,我们的作用域名称是 @abstractmachineslab
代替。
Source
如果你有一个正在运行的 Rust 工具链,你可以通过源代码在本地安装它:
curl https://codeload.github.com/AbstractMachinesLab/hotstuff/tar.gz/main > hotstuff.tar.gz
tar xzf main.tar.gz
cd hotstuff
make install
然后 hotstuff
应该在全球可用。
Features
Incremental Builds
每次运行 hotstuff build
都会计划构建整个站点,但是 它只会执行使您达到最终状态所需的位。
没有内存中的构建状态,而是实施了构建计划差异 在产生的工件之上。
你总是可以调用 hotstuff build --force
来跳过 diffing 和 redo al 工作。
Local Server
您可以运行 hotstuff serve
以增量方式启动静态文件服务器 编译和热重载。
没有内存中的构建状态,构建差异在 背景给你。 因此,您可以在更改后的几毫秒内重新构建 一个文件,浏览器只会重新加载更改的资产。
没有比这更交钥匙的了。
Templating
您很快就会注意到,从 Markdown 到 HTML 的纯编译不会 非常适合所有用例。 为了缓解这种hotstuff
,您可以在您的 site
文件一个模板文件,用于其中的所有 Markdown 文件 具体网站。
假设您想将上面示例中的所有页面包装在一个通用的 标记:为所有这些添加 。 你会写一个模板 文件:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
{| document |}
</body>
</html>
在您的 site
文件中,您将指向它:
(template "path/to/template.html")
瞧! 这就是启动和运行模板所需的全部。
Assets
要复制资产(任何支持文件到您的站点),您可以使用 (assets ...)
规则:
(assets
style.css
logo.svg
bg_music.midi)
它们将自动从它们的位置复制,相对于 站点
文件。
您还可以使用简写 .
而不是列出您的资产以拥有所有 文件夹中的文件复制过来。 这不是递归的。
Credits
hotstuff 的灵感来自现有技术:
- the
cactus
static site generator - the
dune
build system, with its composability - the
bazel
build system, with its aggressive incremental compilation techniques
如果您想支持这个项目,请考虑在 Patreon 上这样做:
???? hotstuff
A composable, incremental, turnkey document compiler
Read the blog post: AM010 - Hot Stuff
hotstuff is turnkey — it makes almost no assumptions about how you structure or write your content. There's also no plugins whatsoever.
hotstuff is composable — touch a few files in your existing folder structure and it'll just work. Near zero-cost, and your content is always fully portable.
hotstuff is incremental —- it aggressively caches your project so you can use it on hundreds of thousands of files.
Just one command away:
- Cargo:
cargo install github.com/AbstractMachinesLab/hotstuff
- Yarn:
yarn global add @abstractmachines/hotstuff
- NPM:
npm install --global @abstractmachines/hotstuff
Getting Started
If you put a hotstuff-project
file on the root of your project, hotstuff will look throughout your whole project for site
files.
site
files tell hotstuff
that this particular folder should be compiled into a website.
So if you have your posts in the following structure:
my/website λ tree
.
├── pages
│ ├── First-post.md
│ └── Some-other-post.md
└── sections
├── about.md
├── hire-me.md
└── projects.md
You just need to touch
a few files:
my/website λ touch hotstuff-project
my/website λ touch pages/site sections/site
And you can run hotstuff serve
to compile the website using the same tree structure under a _public
folder, and serve it with hot-reloading.
my/website λ hotstuff serve
11:19:09 INFO :: Building project...
11:19:09 INFO :: Built 9 artifacts in 6ms
11:19:09 INFO :: Done in 7ms
11:19:09 INFO :: Server listening on http://0.0.0.0:4000
Now your file structure looks like:
my/website λ tree
.
├── _public
│ ├── pages
│ │ ├── First-post.html
│ │ └── Some-other-post.html
│ └── sections
│ ├── about.html
│ ├── hire-me.html
│ └── projects.html
├── hotstuff-project
├── pages
│ ├── First-post.md
│ ├── Some-other-post.md
│ └── site
└── sections
├── about.md
├── hire-me.md
├── projects.md
└── site
Note that the _public
folder is ready for you to serve however you feel like. Upload to S3, Now, GCS, Github pages, or wherever really.
Installation
NPM
If you're already running npm
or yarn
, you can just run yarn global add @abstractmachines/hotstuff
or npm install -g @abstractmachines/hotstuff
to get the right binary in your computer.
If you're running against the Github package registry, our scoped name is @abstractmachineslab
instead.
Source
You can install it locally via source if you have a running Rust toolchain with:
curl https://codeload.github.com/AbstractMachinesLab/hotstuff/tar.gz/main > hotstuff.tar.gz
tar xzf main.tar.gz
cd hotstuff
make install
Then hotstuff
should be available globally.
Features
Incremental Builds
Running hotstuff build
will plan a build of your entire site every time, but it will only execute the bits required to get you to your end state.
There is no in-memory build state, and instead build plan diffing is implemented on top of the artifacts that are produced.
You can always call hotstuff build --force
to skip the diffing and redo al the work.
Local Server
You can run hotstuff serve
to start up a static file server with incremental compilation and hot-reloading.
There's no in-memory build state, and the build diffs are recomputed in the background for you. So you get a re-build within a few milliseconds of changing a file, and the browser will only reload the assets that changed.
It doesn't get anymore turnkey than this.
Templating
You'll quickly notice that the bare compilation from Markdown to HTML doesn't quite fit all use-cases. To alleviate this hotstuff
lets you specify in your site
file a template file to be used for all the Markdown files within that specific site.
Say you wanted to wrap all of the pages from the example above in a common markup: add a <meta charset="utf-8">
to all of them. You'd write a template file:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
{| document |}
</body>
</html>
And in your site
file you'd point to it:
(template "path/to/template.html")
Voila! That's all it takes to get the templating up and running.
Assets
To copy assets (any supporting file to your site) you can use the (assets ...)
rule:
(assets
style.css
logo.svg
bg_music.midi)
And they will be automatically copied from their location, relative to the site
file.
You can also use the shorthand .
instead of listing your assets to have all the files in the folder copied over. This is not recursive.
Credits
hotstuff is inspired by prior art:
- the
cactus
static site generator - the
dune
build system, with its composability - the
bazel
build system, with its aggressive incremental compilation techniques
If you'd like to support this project consider doing so on Patreon:
你可能也喜欢
- 996dev-emoji 中文文档教程
- @5app/logger 中文文档教程
- @aatif-packages/components 中文文档教程
- @absolute-web/vsf-cache 中文文档教程
- @achil/react-infinite-scroll-component 中文文档教程
- @acid-tango/lokalise-downloader 中文文档教程
- @adaept/ae-icon5-component 中文文档教程
- @adidas/yarn-plugin-choicesjs-stencil 中文文档教程
- @adobe/reactor-extension-cloud-connector-edge 中文文档教程
- @advanced-rest-client/arc-cookies 中文文档教程